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

What are inheritAttrs: false and $attrs used for in Vue?

Have a look at the “Disabling Attribute Inheritance” section of the docs and the api description for the full details. It’s main usage is to define so-called “transparent” components that pass-through attributes. The example given in the doc is a component wrapping an input element: // Component Vue.component(‘base-input’, { inheritAttrs: false, props: [‘label’, ‘value’], template: … Read more

Vue.js pass function as prop and make child call it with data

Normally, the click event handler will receive the event as its first argument, but you can use bind to tell the function what to use for its this and first argument(s): :clicked=”clicked.bind(null, post) Updated answer: However, it might be more straightforward (and it is more Vue-standard) to have the child emit an event and have … Read more

Resolve “Property does not exist on type ‘Vue'” error

I had the same problem but with exporting a component. Some vs code snippets create templates without necessary types like this below export default { data() { return { x: “something”, }; }, methods: { rename(name: string) { this.x = name; }, }, }; The problem was I did not add defineComponent() to export default. … Read more