父組件傳了一個屬性,我需要用這個屬性發(fā)請求,如果把請求放在mounted里就會只執(zhí)行一次,以后再觸發(fā)更新,子組件不會重新渲染,如果把請求放在beforeUpdate和updated里 就會無限發(fā)請求;mounted() { var vm=this; function firstData(){ vm.$http({ method:'GET', url:''+vm.test, emulateJSON: true }).then(function(response){ var dataJson=JSON.stringify(response.data) console.log(dataJson) vm.tableData=response.data }) }; firstData()},beforeUpdate() { var vm=this; function firstData(){ vm.$http({ method:'GET', url:'/asp-webapp/entities/ent_Division/findChildren/'+vm.test, emulateJSON: true }).then(function(response){ var dataJson=JSON.stringify(response.data) console.log(dataJson) vm.tableData=response.data }) }; firstData()},
vue2 mounted,beforeUpdate,updated問題
德瑪西亞99
2018-10-02 09:23:35