解决方法:

在vue项目的根目录下添加 vue.config.js文件,文件中需要按照下面写法来写
module.exports = { lintOnSave: true, devServer: { proxy: { // proxy all
requests starting with /api to jsonplaceholder '/api': { target:
'http://localhost:8080', //代理接口 changeOrigin: true, pathRewrite: { '^/api':
'/mock' //代理的路径 } } } } }
然后你就可以在代码中使用 /api 来代替http://localhost:8080 <http://localhost:8080>/mock啦

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信