在列表頁(yè)使用vue傳值給詳情頁(yè)后,詳情頁(yè)中又增加了新的數(shù)據(jù)請(qǐng)求vue渲染,但是返回后打開另一個(gè)詳情頁(yè)vue數(shù)據(jù)還在,沒有重置,vm數(shù)據(jù)重置了,但是再次請(qǐng)求的item數(shù)據(jù)還在,依舊重復(fù)使用。//窗口隱藏時(shí),重置頁(yè)面數(shù)據(jù)mui.plusReady(function(){varself=plus.webview.currentWebview();self.addEventListener("hide",function(e){window.scrollTo(0,0);vm.resetData();},false);});這是頁(yè)面vm數(shù)據(jù)的重置代碼,怎么重置item數(shù)據(jù)呢?varnews=newVue({el:'#news',data:{items:[],//列表信息流數(shù)據(jù)},functionconvert(items){varnewItems=[];items.forEach(function(item){newItems.push({id:item.id,useride:item.useride,fukanid:item.fukanid,pingtime:item.pingime,avatars:'http://werd.imwork.net:90/public/'+item.avatars,time:getDateDiff(item.pingtime),usernames:item.usernames,pingcongtent:item.pingcongtent,});});returnnewItems;};這是新的vue請(qǐng)求數(shù)據(jù),請(qǐng)問(wèn)怎么點(diǎn)擊返回后將item的數(shù)據(jù)也重置呢??
vue返回后重置頁(yè)面數(shù)據(jù)
森林海
2019-05-12 14:02:38