1.用线上地址替换之前的本地地址
在vue.config.js中
//本地
//const targetUrl = 'http://192.168.1.195/'
//线上
const targetUrl = 'https://www.xxxxxx.cn/'
devServer: {
open: true,
// host: 'localhost',
host: '192.168.1.130',
port: 3333,
https: false,
//以上的ip和端口是我们本机的;下面为需要跨域的
proxy: {//配置跨域
'/api': {
target: targetUrl,//这里后台的地址模拟的;应该填写你们真实的后台接口
ws: true,
changOrigin: true,//允许跨域
pathRewrite: {
'^/api': ''//请求的时候使用这个api就可以
}
}
}
},
2.是否需要配置单页应用的基路径
// router->index.js中
const router = new VueRouter({
routes,
// mode: 'hash', // hash模式
mode: 'history', // 访问路径不带#号
base: '/merchant' // 配置单页应用的基路径
})