Registering vue components globally

This is easy to accomplish. You can register components globally in the main.js file. import MyComponent from ‘@/components/MyComponent’ Vue.component(‘my-component-name’, MyComponent) Now you can use <my-component-name /> everywhere. A cleaner way, without bloating your main.js, is to import your component in an index.js file in your components folder like this. import Vue from ‘vue’ import MyComponent … Read more

vue: Uncaught TypeError: Cannot read property … of undefined

Just use v-if on a common parent to all the elements in your template relying on that AJAX call, not around each one. So instead of something like: <div> <h1 v-if=”foo.title”>{{ foo.title }}</h1> <p v-if=”foo.description”>{{ foo.description }}</p> </div> Do <div> <template v-if=”foo”> <h1>{{ foo.title }}</h1> <p>{{ foo.description }}</p> </template> </div>

Why did I get blank (empty) content when I used async setup() in Vue.js 3?

Your component’s async setup() looks fine other than the missing await res.json(), which still wouldn’t cause the problem you’re seeing. I suspect your usage of <Suspense> is incorrect. To use async setup() in a component, the parent component must use that component in a <Suspense> tag: <!– Parent.vue –> <template> <Suspense> <MyAsyncComponent /> </Suspense> </template> … Read more

Vue-Test-Utils Unknown custom element:

Add the router-link stub to the shallow (or shallowMount) method options like this: const wrapper = shallow(TempComponent, { propsData: { temp }, stubs: [‘router-link’] }) or this way: import { RouterLinkStub } from ‘@vue/test-utils’; const wrapper = shallow(TempComponent, { propsData: { temp }, stubs: { RouterLink: RouterLinkStub } }) The error should go away after … Read more