首先安装vue-cli,创建项目
如果没有vue.config.js,则手动创建该文件
附上代码
const webpack = require('webpack')
module.exports = {
devServer: {
proxy: {
'/gettype': {
//目标接口域名
target: 'http://127.0.0.1:80',
//是否进行跨域
changeOrigin: true,
//若是http请求,则要配置该参数
secure:true,
pathRewrite:{
//只要是以api为开头的域名,指定到target中
'^/gettype':''
},
ws: false
}
}
},
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
$:"jquery",
jQuery:"jquery",
"windows.jQuery":"jquery"
})
],
},
publicPath: './',
}