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
提交
取消