javascript 我在哪里可以找到cordova.js?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17651496/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where do I find cordova.js?
提问by Erdem Güng?r
I'm writing a mobile app with HTML5, Javascriptand CSS3. I'm using phonegap.
我正在用HTML5、Javascript和CSS3编写一个移动应用程序。我正在使用 phonegap。
So if I use something like this.
所以如果我使用这样的东西。
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", onBackKeyDown, false);
}
function onBackKeyDown() {
alert("test");
}
I get this error:
我收到此错误:
cordova : You must have cordova.js included in your projects, to be able to trigger events.
cordova :您的项目中必须包含cordova.js,才能触发事件。
I'm using Rippleto emulate a smartphone. And its right. I don't have cordova.js
in my project folder, because I don't know where i get it.
I have downloaded the newest version 2.9.0 of phonegapand using specially cordova-mobile-spec.
我正在使用Ripple来模拟智能手机。它的权利。我没有cordova.js
在我的项目文件夹,因为我不知道我得到它。我已经下载了phonegap的最新版本 2.9.0,并特别使用了cordova-mobile-spec。
There is no cordova.js
just a cordova-incl.js
. How do I obtain this file?
不cordova.js
只是一个cordova-incl.js
. 我如何获得这个文件?
采纳答案by Arjun T Raj
Check the cordova.js
inside the new project created (by using command line)
检查cordova.js
内部创建的新项目(通过使用命令行)
OR
或者
CHECK YOUR LIB FOLDE INSIDE THE DOWNLOADED CORDOVA ZIP FILE
在下载的 CORDOVA ZIP 文件中检查您的 LIB 文件夹
FOR IOSCHECK cordovalibfolder
FOR IOS检查 cordovalib文件夹
ANDROID
安卓
Please check libs folder of each platform.
请检查每个平台的 libs 文件夹。
回答by George Siggouroglou
I wasted a lot of time looking for a solution on the question "Where get the cordova.js?".
I am developing a mobile app using html+css+jQuery mobile and i am building it using the phonegap web build service. The version of phonegap i am working on is 3.1.0.
我浪费了很多时间来寻找“从哪里获得cordova.js?”这个问题的解决方案。
我正在使用 html+css+jQuery mobile 开发一个移动应用程序,我正在使用phonegap web build service构建它 。我正在使用的 phonegap 版本是 3.1.0。
I was trying to find how to use the Phonegap APIon my mobile application and how to call the cordova methods (ex notification.alert). The solution to this is to just add the
我试图找到如何在我的移动应用程序上使用Phonegap API以及如何调用cordova 方法(例如notification.alert)。解决这个问题的方法是添加
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
inside the head of your index.html document. The Phonegap builder will find and include the correct cordova.js file for each build (Android, Win phone, iOS).
在 index.html 文档的头部内。Phonegap 构建器将为每个构建(Android、Win 手机、iOS)查找并包含正确的cordova.js 文件。
Finally, the ondeviceready eventis essential to any application. See the Full Example.
最后,ondeviceready 事件对于任何应用程序都是必不可少的。请参阅完整示例。
回答by Cristiano Dalbem
I also wasted a lot of time trying to figure out what was going on here, because not even George's solution was working for me.
我还浪费了很多时间试图弄清楚这里发生了什么,因为即使是 George 的解决方案也不适合我。
Finally I realized that, as my index.htmlpage is not in the root of the wwwfolder, but inside a subdirectory of it, I should be then setting a relative path for the cordova file (i.e. src="../cordova.js"
).
最后我意识到,由于我的index.html页面不在www文件夹的根目录中,而是在它的子目录中,我应该为cordova 文件(即src="../cordova.js"
)设置一个相对路径。
Hope it helps anyone else having the same [dumb] issue.
希望它可以帮助其他有相同 [愚蠢] 问题的人。
回答by Netham
If you are trying to run on your browser for testing, it is suggested to build for browser and run from there, because every time you build the right cordova.js file is included according to the platform.
如果您尝试在浏览器上运行进行测试,建议为浏览器构建并从那里运行,因为每次构建时都会根据平台包含正确的cordova.js 文件。
To build for browser:
为浏览器构建:
cordova build browser
科尔多瓦构建浏览器
To run:
跑步:
cordova run browser
科尔多瓦运行浏览器
More options
更多的选择
cordova run browser -- --port=8001 --target=Firefox
cordova 运行浏览器 -- --port=8001 --target=Firefox
To run with plugins here is a quick intro guide https://www.raymondcamden.com/2016/03/22/the-cordova-browser-platform
在这里使用插件运行是一个快速介绍指南https://www.raymondcamden.com/2016/03/22/the-cordova-browser-platform