Vue开发环境跨域访问问题
时间:2021-02-18 11:21:06|栏目:vue|点击: 次
Vue开发环境跨域访问其他服务器或者本机其他端口,需要配置项目中config/index.js文件,修改如下
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api':{
target:'http://192.168.1.99:8080/',
changeOrigin:true,
pathRewrite:{
'^/api':''
}
}
},
其中主要是加入
proxyTable: {
'/api':{
target:'http://192.168.1.99:8080/',
changeOrigin:true,
pathRewrite:{
'^/api':''
}
}
}
这样你通过axios 或fetche访问 /api/** 便相当于跨域访问了 http://192.168.1.99:8080/
总结
以上所述是小编给大家介绍的Vue开发环境跨域访问问题,希望对大家有所帮助!
上一篇:vue forEach循环数组拿到自己想要的数据方法
栏 目:vue
下一篇:Vue表单验证插件Vue Validator使用方法详解
本文标题:Vue开发环境跨域访问问题
本文地址:http://www.codeinn.net/misctech/65427.html






