我正在使用jqm 1.4.5。
当用户左右滑动时,我想要更改页面 所以我创建了这段代码:
$( document ).on( "pageinit", ".my-page", function() {
$( document ).on( "swipeleft swiperight", ".my-page", function( e ) {
var prevLink = <some url>;
var nextLink = <some url>;
if ( e.type === "swipeleft" ) {
$( ":mobile-pagecontainer" ).pagecontainer( "change", nextLink, { reloadPage: true});
} else if ( e.type === "swiperight" ) {
$( ":mobile-pagecontainer" ).pagecontainer( "change", prevLink, { reloadPage: true});
}
}
});
我在控制台日志中收到此错误:
Uncaught TypeError: Cannot read property '0' of undefined
符合此代码:
$( ":mobile-pagecontainer" ).pagecontainer( "change", nextLink, { reloadPage: true});
答案 0 :(得分:0)
所以经过很长一段时间的搜索,我得到答案 只需更改:
$( ":mobile-pagecontainer" ).pagecontainer( "change", nextLink, { reloadPage: true});
要:
$.mobile.pageContainer.pagecontainer("change", nextLink);
像魅力一样: - )