All,
所有,
Could you please help me with following. I am trying to access the camera API using cordova. I have created the project using cordova cli. My config.xml has this option added to allow the camera plugin which is also installed using cordova cli.
你能跟我帮忙吗?我正在尝试使用cordova访问相机API。我使用cordova cli创建了这个项目。我的config.xml添加了此选项以允许使用cordova cli安装的相机插件。
<feature name="Camera">
<param name="android-package" value="org.apache.cordova.camera.CameraLauncher" />
</feature>
When I click the camera Button, I find the navigator.camera object as undefined. I have tried it on couple of phones and it seems to be the same issue. I tried remote debugging using chrome and it also shows the camera object as undefined.
当我单击相机按钮时,我发现navigator.camera对象未定义。我已经在几部手机上试过它,这似乎是同样的问题。我尝试使用chrome进行远程调试,它还将相机对象显示为未定义。
Cordova.js load fails with following object as undefined
Cordova.js加载失败,以下对象为undefined
Uncaught TypeError: Cannot set property 'require' of undefined (cordova.js)
未捕获的TypeError:无法设置undefined的属性'require'(cordova.js)
//Export for use in node
if (typeof module === "object" && typeof require === "function") {
module.exports.require = require;
module.exports.define = define;
}
Cordova.js version is 3.7.1 .
Cordova.js版本是3.7.1。
Please note :Commenting these 3 lines from Cordova.js in platform_www seems to fix the issue. But i am wondering if someone can help suggest whats wrong here. Modifying the lib is the last option.
请注意:在platform_www中评论来自Cordova.js的这3行似乎可以解决这个问题。但我想知道是否有人可以帮助建议这里有什么不对。修改lib是最后一个选项。
2 个解决方案
#1
5
the problem could be with the declaration of a variable named module
, in my case it was
问题可能在于声明一个名为module的变量,在我看来是这样的
var module = ons.bootstrap('my-app', ['onsen']);
just rename module in something else.
只需将模块重命名为其他内容。
#2
0
You can't test hybrid app on browser without proper tools. Use ripple chrome extension to test your app.
没有适当的工具,您无法在浏览器上测试混合应用程序使用ripple chrome扩展程序测试您的应用。
https://chrome.google.com/webstore/detail/ripple-emulator-beta/geelfhphabnejjhdalkjhgipohgpdnoc?hl=en
#1
5
the problem could be with the declaration of a variable named module
, in my case it was
问题可能在于声明一个名为module的变量,在我看来是这样的
var module = ons.bootstrap('my-app', ['onsen']);
just rename module in something else.
只需将模块重命名为其他内容。
#2
0
You can't test hybrid app on browser without proper tools. Use ripple chrome extension to test your app.
没有适当的工具,您无法在浏览器上测试混合应用程序使用ripple chrome扩展程序测试您的应用。
https://chrome.google.com/webstore/detail/ripple-emulator-beta/geelfhphabnejjhdalkjhgipohgpdnoc?hl=en