为了账号安全,请及时绑定邮箱和手机立即绑定

为什么这个api不会产生跨域?

为什么这个api不会产生跨域?

收到一只叮咚 2018-10-24 11:06:49
这个测试项目没有做跨域处理 为什么第一个api能获取到数据 而第二个api就会产生跨域呢 提示No 'Access-Control-Allow-Origin' header is present on the requested resource. 这是为什么?<template>    <div class="txt">    </div></template><script>export default {  name: 'Test2',   mounted () {    this.$http.get('http://api.komavideo.com/news/list').then(res => {      console.log(res)     })   } }</script><style scoped></style><template>    <div class="txt">    </div></template><script>export default {  name: 'Test2',   mounted () {    this.$http.get('http://api.douban.com/v2/movie/in_theaters').then(res => {      console.log(res)     })   } }</script><style scoped></style>
查看完整描述

1 回答

?
慕哥9229398

TA贡献1877条经验 获得超6个赞

因为在XHR2中,只要被调用站允许跨站访问,就不会被拦截。默认情况下不开启。

查看完整回答
反对 回复 2018-10-24
  • 1 回答
  • 0 关注
  • 894 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信