原因是,在第一种情况下,JQM做页面更改。在第二种情况下,您通过更改位置手动更改页面。 jQuery使用ajax更改的页面会获得页面转换。
要将切换转换为幻灯片,您可以配置默认设置$.mobile.defaultPageTransition = "slide";
。
使用$.mobile.changePage()
函数来更改页面。 changePage()
函数会为你做页面转换。
<!-- html -->
<a class="testLink" data-transition="slide">abc</a>
// JS
$(document).off('pagechange');
$(document).on('pagechange', function (e, ui) {
// generally written in pagechange event.
$('.testLink').off();
$('.testLink').on('click', function (e) {
$.mobile.changePage('test.html', {
changeHash: true,
dataUrl: "test", //the url fragment that will be displayed for the test.html page
transition: "slide" //if not specified used the default one or the one defined in the default settings
});
});
});
我不明白。为什么?你会从第一个选项得到相同的结果。为什么不使用第一个选项? – Th0rndike