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; }