VUE路由设置history模式刷新404处理
分类:vue
vue路由配成history模式,需要设置base,如果不设置base刷新页面会报404错误
const router = new Router({
mode: 'history',
base: '/weegClient/',
routes
})
打包时vue.config.js配置
module.exports = {
// publicPath: '/', // 根路径 /pages/dist/
publicPath: '/weClient', // 根路径 /pages/dist/
nginx配置
location /weegClient {
#root html;
alias html\weegClient;
try_files $uri $uri/ /weClient/index.html;
index index.html index.htm;
}
一线大厂高级前端编写,前端初中阶面试题,帮助初学者应聘,需要联系微信:javadudu