简体   繁体   English

具有page.js路由的Phonegap仅在桌面上有效

[英]Phonegap with page.js routes works only on desktop

I am using page.js in an HTML+CSS+JS app. 我在HTML + CSS + JS应用程序中使用page.js。

The routes work perfectly in browser, even using the "phonegap serve" and accessing my_ip:3000. 即使使用“ phonegap服务”并访问my_ip:3000,路由在浏览器中也能正常工作。

But when I try to load it in my phoneGap Developer (in an Android phone), only the first route loads (if I try to navigate through the app links, I get only blank screens). 但是,当我尝试在我的phoneGap Developer(在Android手机中)中加载它时,只会加载第一条路线(如果尝试浏览应用程序链接,则只会显示空白屏幕)。

When using page.js in mobile apps (with cordova, phonegap or cocoon), just use: 在移动应用程序(带有cordova,phonegap或茧)中使用page.js时,只需使用:

page( { dispatch: false } )
page( '/' )

Instead of: 代替:

page()

You can replace '/' with the first route that you want your app to start with. 您可以将'/'替换为您希望应用开始的第一个路由。


In details: 详细说明:

Normally, in a web app, you use page() to start the routing process and, of course, it will identify which route is being requested and call the correspondent function. 通常,在Web应用程序中,您可以使用page()启动路由过程,当然,它将识别正在请求的路由并调用相应的函数。

Since in mobile we don't have an URL request, we disable this identification process with dispatch: false and pass a default start route. 由于在移动设备中我们没有URL请求,因此我们使用dispatch: false禁用此标识过程,并传递默认的起始路线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM