简体   繁体   English

在 phonegap 中使用服务器端 html+js(多平台移动开发)

[英]Using server side html+js in phonegap (multiplatform mobile dev)

Phonegap uses html source located in www folder. Phonegap 使用位于 www 文件夹中的 html 源。 I was testing what happens if index.html is still in www, but it links to other html that are located in at the server side.我正在测试如果 index.html 仍在 www 中会发生什么,但它链接到位于服务器端的其他 html。 It will open the server side html in the web browser instead of handle it as part of the app.它将在 web 浏览器中打开服务器端 html,而不是将其作为应用程序的一部分处理。

Is there any way to make phonegap work with server side html + js source?有什么方法可以使 phonegap 与服务器端 html + js 源一起工作?

It is not a bad idea if you need to mix usage of libraries (jars + ios libraries), local phonegap html+js with server side dynamic html code (like php output).如果您需要混合使用库(jars + ios 库)、本地 phonegap html+js 与服务器端动态 html 代码(如 ZE1BFD762321E409CEE4AC0B6E84193 输出),这不是一个坏主意。

thanks.谢谢。

Phonegap is designed to deploy a client, a web app inside a native web view. Phonegap 旨在在本地 web 视图中部署客户端,即 web 应用程序。 You can write a server side API for returning any information your app may need and you can modify the DOM using JS.您可以编写一个服务器端 API 来返回您的应用程序可能需要的任何信息,并且您可以使用 JS 修改 DOM。 There are great templating solutions out there such as mustache.js.有很棒的模板解决方案,例如 mustache.js。 The idea is to write the app fully in JS and retrieve information from the server using any of Ajax implementations in your favourite JS framework.这个想法是完全用 JS 编写应用程序,并使用您最喜欢的 JS 框架中的任何 Ajax 实现从服务器检索信息。 You shouldn't need any dynamic JS.你不应该需要任何动态 JS。 Just information to template and insert into the DOM.只是要模板化并插入到 DOM 中的信息。

I can't find any reasonable explanation anywhere, but the reason why you can't invoke PhoneGap API's when html is hosted on server-side is because cross-site-scripting issue as the webkit does not allow scripts coming from one domain (ie server) be executed on different domain (localhost-device)我在任何地方都找不到任何合理的解释,但是当 html 托管在服务器端时,您无法调用 PhoneGap API 的原因是跨站点脚本问题,因为 webkit 不允许来自一个域的脚本(即服务器)在不同的域(本地主机设备)上执行

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

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