前端vue解决跨域问题
#向其他网站用axios获取数据的时候跨域,一个简单的方法用前端虚拟服务器
components:{
HomeTitle,
HomeContent
},
created() {
this.$axios.get("/api/movie/subject_search?search_text=top&cat=1002")
.then(res=>{
console.log(res)
})
}。
2改变 proxyTable
proxyTable: {
‘/api’: {
target: ‘https://search.douban.com’, //目标接口域名
changeOrigin: true, //是否跨域
pathRewrite: {
‘^/api’: ‘’ //重写接口
}
},
},
重启cmd就好了