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

这个测试项目没有做跨域处理 为什么第一个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>


收到一只叮咚
浏览 902回答 1
1回答

慕哥9229398

因为在XHR2中,只要被调用站允许跨站访问,就不会被拦截。默认情况下不开启。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Vue.js