1、在对应的多页目录下的router.js配置history
const router = new Router({
base: '/mobile/share',
mode: 'history',
},
注:router外面的base属性是我的项目部署服务器的目录门路,例如你的我的项目拜访门路是www.xxx.com/mobile/share
2、在vue.congig.js增加代码
configureWebpack: {
devServer: {
historyApiFallback: {
verbose: true,
rewrites: [
{ from: '/xx', to: '/yy.html'}
]
}
}
},
注:from指你多页中进入其中一个页面index的路由门路,to示意重写到yy.html 至于多页配置自行搜寻,留神的是批改vue.config.js须要重新启动才会失效。
3、重启输出localhost:8080/xx就能够拜访到yy.html的代码
补充:如果部署到nginx服务器,发现报404,就须要nginx部署批改下代码
location / {
root /software/vue/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
location /xx {
root /software/vue/dist;
index yy.html;
try_files $uri $uri/ /yy.html;
}
root:我的项目dist上面的文件部署的根目录
发表回复