When using the lazy loading method to import the sub-route vue file, sometimes an error will be reported! ! !

Insert picture description here
This is wrong! ! ! Just outrageous! ! !

Uncaught SyntaxError: Unexpected token '<'

I configured two sub-routes called HomeNews and HomeMessage in my home and
Insert picture description here
introduced them into index.js under the router through lazy loading. The
Insert picture description here
correct operation! ! !

Yes, the browser sometimes displays normal jumps normally, but it's abnormal when jumping around.

One Month Later

After I changed the way it was introduced, no more errors were reported. (I don't know the principle)

import HomeMessage from '../views/HomeMessage';
import HomeNews from "../views/HomeNews";

Maybe I haven’t learned enough, there should be other ways to solve it, and I would like to ask the big guys for advice.

Finally, remember to re-npm run serve! ! !

Guess you like

Origin blog.csdn.net/weixin_45773503/article/details/113761222