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里有大概是这样的json在html里 用 {{ sendMessage }} 引用数据了sendMessage并没有改变值是不是不能这么写函数?
添加回答
举报
0/150
提交
取消