vue数据加载不出

new Vue({

     el: '.wrap',

     data: {

         addressList: [],

         productList: [],

         sendMessage: ''

     },

     mounted: function() {

     this.$nextTick(function() {

         this.getAddressList();

         this.getProductList();

         this.getSendMessage();

     });

     },

     methods: {

         getAddressList: function() {

             this.$http.get('data/address.json', {}).then(res => {

             this.addressList = res.data.result;

             });

         },

         getProductList: function() {

             this.$http.get('data/cart.json', {}).then(res => {

             this.productList = res.data.result.productList;

             });

         },

         getSendMessage: function() {

             var _this = this;

             this.addressList.forEach(function(item, index) {

                 if (item.isDefault) {

                      _this.sendMessage = item.streetName + item.userName + item.postCode;

                 }

             });

         }

    }

});

其他地方都正常运行了

this.addressList返回的是json数据

streetName userName postCode 都在json里有

大概是这样的jsonhttp://img.mukewang.com/58f35fbb0001586106140309.jpg


在html里 用 {{ sendMessage }} 引用数据了

sendMessage并没有改变值

是不是不能这么写函数?

下雨不停的雨婷
浏览 3546回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Vue.js