<a href="#page2?golfer=arnoldpalmer"></a>
我刚试过,但它不起作用。jQuery手机似乎去掉了链接的?golfer=arnoldpalmer部分(你可以通过查看源码看到这一点)。有什么变通方法或解决方案吗?
这是不是因为我们的标准是我们不能把参数放在页面哈希链接后面?
发布于 2014-03-26 17:00:51
正如@zyrex指出的那样,有“纯粹的”jQuery移动解决方案。
另一个流行的解决方案是依赖于Backbone Routers,它提供了对URL中参数的开箱即用的解析。
如果您使用此功能,则必须使用以下命令停用JQuery移动中的哈希标签拦截
$( document ).on( "mobileinit",
// Set up the "mobileinit" handler before requiring jQuery Mobile's module
function() {
// Prevents all anchor click handling including the addition of active button state and alternate link bluring.
$.mobile.linkBindingEnabled = false;
// Disabling this will prevent jQuery Mobile from handling hash changes
$.mobile.hashListeningEnabled = false;
}
)在路由器中创建路由
routes: {
"": "start",
"page2/:golfer": "gotopage2"
}并在您的处理程序中执行JQM导航。
gotopage2: function( golfer ) {
//do something with golfer
//show JQM page
$.mobile.pageContainer.pagecontainer( "change", "#page2")
}发布于 2014-03-26 16:28:29
这应该可以解决您的问题:)有三种传递参数的方法。Value Passing In Jquery from one html class to other html class in PhoneGap
https://stackoverflow.com/questions/22654896
复制相似问题