美文网首页
2019-04-17vue项目用后台json数据做列表循环

2019-04-17vue项目用后台json数据做列表循环

作者: 泡沫双鱼座 | 来源:发表于2019-04-23 13:49 被阅读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

相关文章

网友评论

      本文标题:2019-04-17vue项目用后台json数据做列表循环

      本文链接:https://www.haomeiwen.com/subject/phonwqtx.html