proxyTable失效问题中的其中一个bug
今天处理vue的proxyTable时老是不调用proxyTable方法,路径错误报错404!网上查找了很久都没找到合适自己的方法,接口路径什么的都没写错,后来我发现把已经加载的node_modules删除从新npm install然后从新打开npm run dev然后就不报错404了,是不是很神奇
node_modules (删除重新构建)
npm install
npm run dev
// config文件夹中的index.js文件
proxyTable: {
// 匹配所有以 /api 开头的url
'/api': {
// 请求的目标主机
target: 'http://xxxxxx.com',
changeOrigin: true,
// 这样重写会把路径中 /api 消去
pathRewrite: {
'^/api': ''
}
}
},
希望对各大网友有些许帮助!