热门搜索 :
考研考公
您的当前位置:首页正文

ionic 3从别的应用跳进当前应用的处理方案

来源:东饰资讯网

1.在页面元素加载之前声明全局event方法,切记一定要在监听事件之前声明

var event = new Event("setItemEvent");

2.注册监听此event,并且处理相应的跳转,并且在跳转之后把该数据删除掉

window.addEventListener("setItemEvent", function (event) {

var urlType = localStorage.getItem("urlTypefromLocal");

if (!urlType || urlType.length == 0){

return;

}

if (urlType.indexOf("temp://") == 0) {

localStorage.removeItem("urlTypefromLocal");

navCtrl.push(LoginPage);

}

});

3.index.html中注入简单的js方法,用于传相应的跳转scheme参数过来,并将此跳转的scheme参数保存到本地缓存用于处理跳转,接到参数的同时分发全局事件event

function temp(e){

localStorage.setItem("urlTypefromLocal",e);

window.dispatchEvent(event);

}

3步完美解决ionic3 应用之间的跳转,欧耶!

Top