vue3路由模式改成html5模式之后,页面不能正常访问了

224 阅读1分钟

问题复现:把路由模式由createWebHashHistory改为createWebHistory的时候,页面不能正常访问了

控制台警告:

[Vue Router warn]: No match found for location with path 

原因:我在vite.config.js中配置了base路径

image.png

解决方法:路由中也要对应设置此路径

image.png

注释:

createWebhistory 函数接受一个参数 base 指的是托管应用程序的文件夹

参考链接:

segmentfault.com/q/101000004…