我编写了一个小测试,用于在 JQuery mobile 的更改功能中使用滑动动画,并且该功能在一定程度上可以正常工作。我遇到的问题是后退按钮无法转到上一页。我将从第 1 页转到第 2 页,然后一旦我返回,它就会转到第 5 页。是否需要在我的页面中手动添加一些内容javaScript 因此它可以正确存储前一页?
这里是 javaScript 和 running example 的片段:
$(document).ready(function () {
$('div[data-role="page"]').on("swipeleft", function(){
var nextpage = $.mobile.activePage.next("[data-role=page]");
if ( nextpage.length ) {
$.mobile.pageContainer.pagecontainer('change', nextpage, {
transition: "slide"
});
}
});
$('div[data-role="page"]').on("swiperight", function(){
var prevpage = $.mobile.activePage.prev("[data-role=page]");
if ( prevpage.length ) {
$.mobile.pageContainer.pagecontainer("change", prevpage, {
transition: "slide", reverse: true
});
}
});
});
谢谢。
最佳答案
您可以在页面上使用 data-url
属性,或使用 change
方法选项中的 dataUrl
属性。
Type: String The URL to use when updating the browser location upon change() completion. If not specified, the value of the data-url attribute of the page element is used.
这是一个使用 data-url
属性的工作示例。
关于javascript - 后退按钮不适用于 JQuery 更改功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31709689/