WEB開発者のハイブリッド開発アプリ(十二)、ページ間のパラメータ伝達方式
2471 ワード
ハイブリッド開発appでは,ページ間のパラメータ伝達方式として,主に以下の2種類を用いた.
伝達パラメータ:
取得パラメータ:products.htmlページ取得パラメータはmuiに書く必要がある.plusReadyでは、次のようになります.
伝達パラメータ:
取得パラメータ:productdetail.htmlでパラメータを取得する方法、カスタムイベントproductInfoで、
Htmlを理解してAppを開発することができて、博文は引き続き更新して、博主QQ:260737830!
1.新規ページのパラメータ転送
伝達パラメータ:
// id
var id = '121212';
// , pid
mui.openWindow({
url:'products.html',
id:'products.html',
extras:{
pid:id
}
});
取得パラメータ:products.htmlページ取得パラメータはmuiに書く必要がある.plusReadyでは、次のようになります.
mui.plusReady(function(){
var self = plus.webview.currentWebview(); // webview
var pid = self.pid == null ? "" : self.pid; // pid
});
2.プリロードページパラメータ転送
伝達パラメータ:
//
var detailPage = mui.preload({
url:'productdetail.html',
id:'productdetail.html'
});
// id
var id ='12222';
// , id
mui.fire(detailPage,'productInfo',{id:id});
//
mui.openWindow({
id:"productdetail.html"
});
取得パラメータ:productdetail.htmlでパラメータを取得する方法、カスタムイベントproductInfoで、
// , id
window.addEventListener('productInfo',function(event){
var id = event.detail.id; // id ,event.detail.xx xx
});
Htmlを理解してAppを開発することができて、博文は引き続き更新して、博主QQ:260737830!