Skip to content
Advertisement

Why is this error not letting me async render Vue Components?

I’m quite new with Vue, and I’m trying to lazy load a Component, I’m getting this error which I don’t understand, there should probably be a syntax error. Here’s the code:

JavaScript

The Modal Comp is just a simple h2 and a p with a red border (I already tried the same code without lazy load, and it works fine). Here’s the error: enter image description here

Advertisement

Answer

By wrapping defineAsyncComponent() in a function, you’re incorrectly declaring the Modal component as a function:

JavaScript

The simplest solution is to remove the function wrapper:

JavaScript

demo

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement