当浏览器向后端接口请求数据时 , 会出现跨域问题 , 出现如下报错
我的后端接口地址是 : https://www.uinav.com/api/public/v1/home/swiperdata
一 , 项目根目录新建 vue.config.js
配置跨域 (两种方法都可以)
"use strict";
const path = require("path");
// module.exports = {
// devServer: {
// proxy: {
// '/api': {
// target: 'https://www.uinav.com',
// changeOrigin: true,
// },
// }
// }
// }
module.exports = {
dev: {
proxyTable: {
'/api': {
target: 'https://www.uinav.com',
changeOrigin: true,
},
},
host: 'localhost',
port: 8080
}
}