When utilizing the <inertia-link> tag, the Vue component fails to render

After implementing the <inertia-link>, I noticed that the child component test.vue is not rendering. It only displays when I remove those tags. Any suggestions on what might be causing this issue?

test.vue

<template>
    <div>
        <div class="p-6 sm:px-20 bg-white border-b border-gray-200">
            <div>
                <b-logo class="block h-12 w-auto" />
            </div>

            <div class="mt-1 text-2xl">
                {{ $page.user.first_name }} {{ $page.user.last_name }}
            </div>

            <inertia-link :href="#">
                test-link
            </inertia-link>

        </div>
    </div>
</template>

<script>
    import BLogo from './BLogo'

    export default {

        components: {
            BLogo,
        },
    }
</script>

The inclusion of this component in another .vue file is through <my-test />

This scenario exists within laravel 8. Additionally, it was observed that using the <inertia-link> tag in the parent vue results in its display. Hence, the tag functionality seems to be working.

(It appears to be utilized by the default Jetstream profile pages).

Answer №1

When implementing the Vue3 code snippet provided by inertiajs on their official website:

import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue3'

createInertiaApp({
  resolve: name => require(`./Pages/${name}`),
  setup({ el, App, props, plugin }) {
    createApp({ render: () => h(App, props) })
      .use(plugin)
      .mount(el)
  },
})

You will need to include the Link component like this:

import { createApp, h } from 'vue';
import { createInertiaApp, Link } from '@inertiajs/inertia-vue3';

createInertiaApp({
  resolve: name => require(`./Pages/${name}`),
  setup({ el, App, props, plugin }) {
    createApp({ render: () => h(App, props) })
      .use(plugin)
      .component('inertia-link', Link)
      .mount(el)
  },
});

Once you have added the inertia-link component, it should work as expected.

Answer №2

To begin, ensure that you have installed all the necessary dependencies.

npm install @inertiajs/inertia @inertiajs/inertia-vue

Alternatively, you can use Yarn:

yarn add @inertiajs/inertia @inertiajs/inertia-vue

Get started by initializing your application.

Then, make sure to update your main JavaScript file in order to boot up your Inertia application. Essentially, this step involves setting up the client-side framework with the basic Inertia page component.

import { InertiaApp } from '@inertiajs/inertia-vue'
import Vue from 'vue'

Vue.use(InertiaApp)

const app = document.getElementById('app')

new Vue({
  render: h => h(InertiaApp, {
    props: {
      initialPage: JSON.parse(app.dataset.page),
      resolveComponent: name => require(`./Pages/${name}`).default,
    },
  }),
}).$mount(app)

If you require Code splitting capabilities, you can follow these additional steps:

Answer №3

Dealing with this particular issue drove me to the brink of madness, but I finally cracked the code on it. The culprit turned out to be <inertia-link>, a custom link that Vue attempts to match with a registered component. When Vue fails to find said component, it triggers a warning. Here's the solution to put this problem to rest.

  • To start, import Link from the Vue adapter of Inertia in your app.js file like so:

    import { Link } from '@inertiajs/inertia-vue'

  • After importing both Vue and Link, go ahead and register the Link as a component with Vue in the same app.js file:

    Vue.component('inertia-link', Link)

Simply use <inertia-link> in your templates and everything should run smoothly.

PS: Just a heads up, I was utilizing Vue2 at the time.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Displaying thousands of records for user selection in C# - A step-by-step guide

I am currently dealing with a large amount of records spread across two tables, and I need to display them on a webpage for user selection. At the moment, I am using dropdowns for this purpose. Here are the requirements: - Users should be able to select m ...

What could be the reason for the cardDetails component, which is supposed to display information received via a Vuex action, not appearing

Recently, I've been diving into Vue and Vuex while working on a small app that showcases events. Users can click on event cards to view more details using the card's ID. I've moved all the code to the Vuex Store, but I'm encountering is ...

Tips for safeguarding the security of my PHP API when accessed through Ajax using OAuth2

I've developed a cross-origin ajax application that utilizes some personal APIs I created. Now, I'm looking to enhance the security measures so only my application has access to the API. After researching, I came across OAuth2 at OAuth2. I foll ...

How can I personalize pagination with the reactable library?

As I work on implementing pagination for a reactable table, I have referred to the documentation which clearly outlines how to add this functionality using itemsPerPage and pageButtonLimit: <Table className="table" data={[ { Name: 'Griffin Smi ...

What could be causing the error when attempting to utilize the VueFire plugin?

I recently attempted importing the Vuefirestore plugin from Vuefire and registering it with vue.use. However, during compilation, I encountered an error message stating: 'Vue' is not defined no-undef for some unknown reason. import { firestorePlu ...

Using VueJS variables within HTML attributes

I've been attempting to assign the src of an element to a JS variable, but I haven't been successful. I've tried various methods without any luck. Here's one method: <source src="{{ this.show.podcastUrl }}" type="audio/mpeg"> An ...

Add attributes to the top level

<li class="page_item"><a href="javascript:">A</a> <ul class="children"> <li class="page_item"><a href="">1</a></li> <li class="page_item"><a href="">2</a></li> </ul> < ...

What is the process for reloading the helper after modifying the values?

After the user selects an option, I am trying to filter information on my page. I created a "change" event and passed values through sessions. The console log shows that the values are being passed correctly. However, it seems like the helper is not refres ...

When compiling the UPDATE query, KNEX has detected undefined bindings

I'm currently using Knex to update a record in a mySQL table, and I keep encountering the following error: "UnhandledPromiseRejectionWarning: Error: Undefined binding(s) detected when compiling UPDATE query: update purchases set name = ?, email = ?, ...

Dynamic segments in Vue Router that depend on a predefined list

Dynamic segments in Vue Router are denoted by a colon at the beginning: { path: '/user/:username', component: User } However, what if I only want to match specific names like: Bob, John, Jane, Chris. I would like to set up something similar to t ...

Storing state or data in React for persistence when users navigate between pages or use the browser's back

In the process of developing a small SNS app with React (Gatsby.js), I encountered a challenge. My goal is to maintain state in previous pages even when navigating back using the browser, similar to popular platforms like Twitter and Instagram. However, I ...

The DateFormat.js script encountered an error: Unexpected token export

While working with some Kubernetes PODS, I suddenly encountered an error in one of the pods. The issue seems to be originating from line 6 of my code. I haven't made any changes recently; I was just deploying on GitLab when I noticed that this particu ...

What is the best way to add an array to my JSON object in Javascript?

I'm currently in the process of formatting an array into a JSON object for API submission. Struggling to find the right method to transform my array into the desired structure. This is what my array looks like: data: [ ["Lisa", "Heinz", "1993-04 ...

Automatically proceed to the following page after the video in the Qualtrics iframe comes to an end

I'm attempting to integrate a vimeo video using an iframe in my Qualtrics survey. Once the video is finished, I want it to automatically move on to the next page by pressing the "next button". Previously, I had my videos stored on Dropbox and used the ...

What problems are being caused by this specific way of assigning variables?

What is the difference in variable assignment when it is inside an object and the "this" variable refers to that object? var prop = this.properties; var properties = this.properties; Compared to: var prop = properties = this.properties; Switching t ...

How can I dictate the placement of a nested Material UI select within a popper in the DOM?

Having trouble placing a select menu in a Popper. The issue is that the nested select menu wants to mount the popup as a sibling on the body rather than a child of the popper, causing the clickaway event to fire unexpectedly. Here's the code snippet f ...

JavaScript and CSOM updates cause SharePoint list item properties to disappear

Within my SharePoint environment, there exists a website where users can load a single list item based on their selection using JavaScript and CSOM. This particular list item contains approximately 60 properties defined in its list definition. Users have ...

Utilizing Vue router: a guide to sending data to the default route

Below is the configuration of my vue router: [ { name: 'home', path: '/', component: HomeComponent, props: true, }, { name: 'detail', path: '/detail/:id', ...

Animate a division with its content to smoothly transition downwards

After a user submits a form, I want to create a smooth animation where the form inputs slowly move down below the header but above the rest of the form. Currently, the form just shifts down abruptly, but I'm looking for a more graceful transition. Be ...

Using a JavaScript function, transmit information through an Express response

I am working on sending an application/javascript response from my Express server, utilizing data retrieved from MongoDB. This response is intended for loading content on a third party website. All components of the process have been developed, and now I ...