vue2.0 豆瓣api跨域 Access-Control-Allow-Origin'
发布于 5个月前 作者 wuyujin 582 次浏览 来自 问答

百度了许久,说在proxyTable加入豆瓣的链接,可以好像没效果 proxyTable: { '/api’: { target: 'http://api.douban.com/v2’, changeOrigin: true, pathRewrite: { '^/api’: ‘/api’ } } },

请求地址: this.$http.get(‘http://api.douban.com/v2/movie/subject/1764796’) .then((res)=>{ console.log(res) },(error)=>{ console.log(error) })

不知道为啥一直报错 XMLHttpRequest cannot load http://api.douban.com/v2/movie/subject/1764796. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8080’ is therefore not allowed access.

pacakage.json文件 "dependencies": { "axios": "^0.16.2", "lodash": "^4.17.4", "vue": "^2.3.3", "vue-cli": "^2.8.2", "vue-resource": "^1.3.4", "vue-router": “^2.6.0” },

哪位大神帮忙看看,刚开始学vue,菜鸟我的卡在这里了。

回到顶部