vue-router error

报错内容:Catch all routes (“*”) must now be defined using a param with a custom regexp.

Meaning: catch all routes ("") must now be defined with a parameter with a custom regex.

Reason: The difference between vue2 and vue3.

Official website tip: If you don't plan to use its name to directly jump to the route not found, you don't need to add * for the repeated parameters. If you call router.push('/not/found/url'), it will provide the correct pathMatch parameter.

Solution:

{
    
    
     // 识别不到的path 自动调转404
     // vue2使用* vue3使用:pathMatch('*') 或者 :pathMatch('*')* 或者 :catchAll(.*)
    path: "/:catchAll(.*)",
    redirect: '/404',
},

おすすめ

転載: blog.csdn.net/qq_45142260/article/details/129085979