例如 http://www.baidu.com/wap 手机端 http://www.baidu.com/pc 后台
1.修改文件 config\index.js
module.exports = {
dev: {
//从原来的 ‘/’改为‘/saas_wap/’
assetsPublicPath: '/saas_wap/',
...
build: {
//从原来的 ‘../dist/index.html’改为‘../dist/saas_wap/index.html’
index: path.resolve(__dirname, '../dist/saas_wap/index.html'),
//从原来的 ‘../dist’改为‘../dist/saas_wap’
assetsRoot: path.resolve(__dirname, '../dist/saas_wap'),
//从原来的 ‘/’改为‘/saas_wap/’
assetsPublicPath: '/saas_wap/',
...
...
2.修改文件 src\router\index.js
const router = new Router({
mode: 'history',
//增加base
base: "/saas_wap/",
routes: [{
...
router.beforeEach((to, from, next) => {
其内所有的 window.location.origin
修改为 window.location.origin + "/saas_wap"
...
3.项目内部的所有的 localStorage的参数名统一修改为wap_参数名或pc_ 以作区分
4.注意项目内部不要使用clear()缓存清除的方法