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;???????????????? }???????????? });?????????} ????}});其他地方都正常運(yùn)行了this.addressList返回的是json數(shù)據(jù)streetName userName postCode 都在json里有大概是這樣的json在html里 用 {{ sendMessage }} 引用數(shù)據(jù)了sendMessage并沒(méi)有改變值是不是不能這么寫函數(shù)?
添加回答
舉報(bào)
0/150
提交
取消