1. 程式人生 > >MUI如何實現返回頁面不重新整理,並獲取上一個頁面的返回值

MUI如何實現返回頁面不重新整理,並獲取上一個頁面的返回值

MUI如何實現返回頁面不重新整理,並獲取上一個頁面的返回值

     MUI中經常需要用到從當前頁面返回到上一個頁面,且不重新整理上一個頁面。

 

實現思路:

1.上一個頁面通過MUI的方式跳轉到當前頁面

2.當前頁面設定設定mui fire,定義上一個頁面的監聽方法,傳送引數

3.在上一個頁面設定監聽,監聽mui fire 返回

實現程式碼:

1、當前頁面

 var self = plus.webview.currentWebview();
		    var opener = self.opener();
		        mui.fire(opener,'refresh',{}); 
	            self.close();
	            opener.show();
		    mui.fire(opener,'selectfiles',{"fileurl":entry.toLocalURL()});
			   self.close();
		    opener.show();

2.上一個頁面

window.addEventListener('selectfiles', function(e){//監聽上一個頁面fire返回
		    alert("dsfsdf");
		    console.log(e.detail.fileurl);

		    }
	 });