IOS移動端從B頁面選擇完數(shù)據(jù)使用this.$router.back()或this.router.go(-1)返回到A頁面時(shí),沒有重新調(diào)用mounted()函數(shù),并且不會帶回B頁面所選的數(shù)據(jù)。
可能是因?yàn)槭褂胟eep-alive,會緩存頁面,導(dǎo)致返回上一個(gè)頁面時(shí)不會觸發(fā)mounted()函數(shù),這時(shí)候可以使用actived()函數(shù)
方法2使用事件總線this. b u s , 可 以 實(shí) 現(xiàn) 在 任 意 組 件 間 通 信 。 B 頁 面 某 個(gè) 方 法 中 發(fā) 送 事 件 t h i s . bus,可以實(shí)現(xiàn)在任意組件間通信。B頁面某個(gè)方法中發(fā)送事件this. bus,可以實(shí)現(xiàn)在任意組件間通信。B頁面某個(gè)方法中發(fā)送事件this.bus. e m i t ( ‘ 你 要 發(fā) 送 的 事 件 ’ , 參 數(shù) ) , A 頁 面 c r e a t e d ( ) 中 接 收 事 件 t h i s . emit(‘你要發(fā)送的事件’,參數(shù)),A頁面created()中接收事件this. emit(‘你要發(fā)送的事件’,參數(shù)),A頁面created()中接收事件this.bus. o n ( ′ 你 要 接 受 的 事 件 ′ , ( 參 數(shù) ) = > / / 執(zhí) 行 對 參 數(shù) 的 操 作 ) , A 頁 面 d e s t r o y e d ( ) 中 關(guān) 閉 事 件 t h i s . on('你要接受的事件',(參數(shù))=>{ //執(zhí)行對參數(shù)的操作 }),A頁面destroyed()中關(guān)閉事件this. on(′你要接受的事件′,(參數(shù))=>//執(zhí)行對參數(shù)的操作),A頁面destroyed()中關(guān)閉事件this.bus.$off(‘你要接受的事件’)
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧