2019-04-17vue项目用后台json数据做列表循环
2019-04-23 本文已影响0人
泡沫双鱼座
第一种
钩子
mounted: function () {
this.cartView();
},
方法:
methods: {
// 显示购物车界面
cartView:function(){
var_this =this;
// 获取商品数据信息
this.$http.get("data/products.json").then(function(res){
_this.productList = res.body.result.list;
console.log(res);
console.log(_this.productList);
})
},
}
第二种
import axios from 'axios'
Vue.prototype.$axios = axios;
created() {
axios.get('static/data.json').then((res) =>{
console.log(res.data.goods)
this.goods = res.data.goods
});
}s