解决跨域的方法
使用代理服务器
在douban项目根目录下面
新建
vue.config.js
module.exports = {
devServer:{
proxy:{
'/api':{
target:'http://localhost:3000',
pathRewrite:{
'^/api':''
}
}
}
}
}
把http://index.js中的basURL,改为 '/api' 如下图:
重启服务器,运行项目
关闭项目 然后再次重启
解决报错