// config 配置文件
const { defineConfig } = require('@vue/cli-service')
// module.exports = defineConfig({
// transpileDependencies: true,
// })
module.exports = {
devServer: {
proxy: {
"/api/": {
target: 'https://echarts.apache.org/examples/data/asset/data/stock-DJI.json',
changeOrigin: true, // 跨域访问设置,true代表跨域
ws: true,
'secure': true, // false为http访问,true为https访问
// 'pathRewrite': { // 路径改写规则
// '^/api': "/" // 以/api/为开头的改写为''
// }
},
},
},
}
// url
let url = '/api/' //// 这里会匹配到前面我们设置的/api/',代替为https://echarts.apache.org/examples/data/asset/data/stock-DJI.json,
console.log('url', url)
this.axios.get(url).then((rawData) => {}
// 运行结果
url /api/
:8081/api/:1 Failed to load resource: the server responded with a status of 404 (Not Found)
// 我希望的是
https://echarts.apache.org/examples/data/asset/data/stock-DJI.json
这个链接 替换 let url = '/api/'
请求 是这样
this.axios.get(https://echarts.apache.org/examples/data/asset/data/stock-DJI.json).then((rawData) => {}
实际请求时
this.axios.get(/api/) => {}
我希望的是
https://echarts.apache.org/examples/data/asset/data/stock-DJI.json
这个链接 替换 let url = '/api/'
请求 是这样
this.axios.get(https://echarts.apache.org/examples/data/asset/data/stock-DJI.json).then((rawData) => {}
实际请求时
this.axios.get(/api/) => {}
到底要怎么搞