vue请求本地json数据

1.下载vue-resource插件

  cnpm install vue-resource

  1.2全局引入vue-resource:

  在main.js

  import VueResource from 'vue-resource';
  Vue.use(VueResource);
 
2.把静态josn文件放在项目根的 static文件夹:
 
3.发送请求:
 
 
getNum() {
this.$http.get("static/data/unusedorder.json").then(data => {
  console.log(data.data.unusedItems);
  });
 
}
 

猜你喜欢

转载自www.cnblogs.com/lan-cheng/p/9216779.html
今日推荐