在vue文件的根本目录下创建一个vue.config.js文件
文件中写入
module.exports = {
devServer:{
proxy:{
'/api':{
target:'http://localhost:3000',
pathRewrite:{
'^/api':''
}
}
}
}
}
target中写入要调用的端口号
调用端口号的时候使用api/就行啦