网络开发新手报告:
我正在使用 jquery mobile 编写我的第一个移动应用程序,目前卡在那里:
对于一些附加功能,我想获取当前事件页面的 url。我发现可以使用 $.mobile.activePage 来完成。例如,以下代码对我来说按预期工作:
$(document).on("pagecreate",function(){
console.log($.mobile.activePage[0].baseURI);
});
但是,当我按“后退”按钮时,Uncaught TypeError: Cannot read property 'activePage' of undefined
出现在控制台中,并且应用程序挂起。
问题:遇到这种情况我该如何处理?谢谢!
最佳答案
您应该做一点不同的事情,使用以下代码:
$(document).on("pageshow",'.ui-page',function(){
console.log($.mobile.activePage[0].baseURI);
});
关于javascript - Jquery 移动事件页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24165841/