为什么site.name显示不出来,本地应该没有跨域问题啊,我在一台电脑上行,一台电脑上不行

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.js"></script>
</head>
<body>
<div id="app">
    {{h}}
<div v-for="site in info">
        {{ site.name }}
      </div>
</div>
<script>
var vm = new Vue
({ 
    el : '#app',
    data :  {info:"",h:"123"},
    mounted () {
    axios
      .get('./db.json')
      .then(response => (this.info = response.data.sites))
      .catch(function (error) { // 请求失败处理
        console.log(error);
      });
    },
});
</script>
</body>
</html>

//db.json
{

"name":"你好",
"num":3,
"sites": [
    { "name":"Google", "info":[ "Android", "Google 哈哈", "Google 哈" ] },
    { "name":"Runoob", "info":[ "Runoob1", "Runoob2", "Runoob3" ] },
    { "name":"Taobao", "info":[ "Taobao1", "Taobao2" ] }
]

}

阅读 2.1k
1 个回答

本地?火狐好像是支持的。chrome不支持。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题