Javascript 如何获取cordova&x27的参考资料;Sencha Touch代码中的s插件
我准备在我的cordova项目中添加一些插件。 但科尔多瓦项目是由Sencha Touch 2生成的 如果我在cordova下添加了一个插件 如何在Sencha Touch代码中获得cordova插件的参考?(因为Sencha Touch代码比cordova插件高一级) 我不应该触摸生成的cordova代码,因为每当我使用Sencha touch CMD命令重新生成cordova项目时,它都会被替换Javascript 如何获取cordova&x27的参考资料;Sencha Touch代码中的s插件,javascript,cordova,sencha-touch,cordova-plugins,Javascript,Cordova,Sencha Touch,Cordova Plugins,我准备在我的cordova项目中添加一些插件。 但科尔多瓦项目是由Sencha Touch 2生成的 如果我在cordova下添加了一个插件 如何在Sencha Touch代码中获得cordova插件的参考?(因为Sencha Touch代码比cordova插件高一级) 我不应该触摸生成的cordova代码,因为每当我使用Sencha touch CMD命令重新生成cordova项目时,它都会被替换 更新 我想通过给出一个场景来澄清我的问题: 例如,我想在Sencha Touch代码中使用摄像
更新 我想通过给出一个场景来澄清我的问题: 例如,我想在Sencha Touch代码中使用摄像头,但通过使用Cordova插件可以访问手机中的本地资源。 当运行Sencha Touch命令生成Cordova项目时,Cordova文件夹下的所有代码都将被覆盖,因此无法在Cordova文件夹下进行编码,这就是为什么所有编码必须在Sencha Touch级别进行的原因 因此,问题变成->如果插件在cordova的范围内,我如何访问sencha touch代码中的摄像头,这意味着cordova插件的访问不在sencha touch的范围内 更清楚地说,以下是Sencha Touch项目的结构,其中包含Cordova项目:
Root folder for Sencha Touch Project
-app
-cordova
-plugins
-...
如你所见,插件位于cordova文件夹下,因此我不知道如何获得摄像头插件的参考,如:
Ext.navigator.camera.function() (like this?)
在Sencha触摸代码中
我希望我的解释对你有意义
谢谢。Cordova插件使用
clobbers
元素在其清单(例如plugin.xml)中声明如何在浏览器运行时内公开功能。target
属性值是添加到窗口对象的属性值,可以在触发deviceready
事件后立即使用
关于plugin.xml和clobbers的更多信息可以找到。我在
为了方便起见,下面是代码
/*
* File: app/view/Picture.js
*
* This file was generated by Sencha Architect version 2.0.0.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Sencha Touch 2.0.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.0.x. For more
* details see http://www.sencha.com/license or contact license@sencha.com.
*
* This file will be auto-generated each and everytime you save your project.
*
* Do NOT hand edit this file.
*/
Ext.define('Contact.view.Picture', {
extend: 'Ext.Container',
alias: 'widget.contactpic',
config: {
height: 120,
minHeight: 100,
style: 'overflow: hidden',
ui: '',
layout: {
align: 'center',
type: 'vbox'
},
overflow: 'hidden',
tpl: [
'<img src="{picture}" width="160" />'
],
items: [
{
xtype: 'component',
html: ''
},
{
xtype: 'button',
bottom: 5,
itemId: 'mybutton',
right: 5,
iconCls: 'add',
iconMask: true
}
],
listeners: [
{
fn: 'onMybuttonTap',
event: 'tap',
delegate: '#mybutton'
}
]
},
onMybuttonTap: function(button, e, options) {
Ext.device.Camera.capture({
source: 'camera',
destination: 'file',
success: function(url) {
this.fireEvent('change', this, url);
},
failure: function() {
Ext.Msg.alert('Error', 'There was an error when acquiring the picture.');
},
scope: this
});
}
});
/*
*文件:app/view/Picture.js
*
*此文件由Sencha Architect 2.0.0版生成。
* http://www.sencha.com/products/architect/
*
*此文件需要使用Sencha Touch 2.0.x库,并获得独立许可。
*Sencha Architect的许可证不包括Sencha Touch 2.0.x的许可证。更多
*详情见http://www.sencha.com/license 或联系license@sencha.com.
*
*每次保存项目时,都会自动生成此文件。
*
*请勿手动编辑此文件。
*/
Ext.define('Contact.view.Picture'{
扩展:“Ext.Container”,
别名:“widget.contactpic”,
配置:{
身高:120,
身高:100,
样式:“溢出:隐藏”,
用户界面:“”,
布局:{
对齐:'居中',
类型:“vbox”
},
溢出:“隐藏”,
第三方物流:[
''
],
项目:[
{
xtype:'组件',
html:'
},
{
xtype:'按钮',
底部:5,
itemId:'mybutton',
右:5,,
iconCls:“添加”,
iconMask:对
}
],
听众:[
{
fn:“onMybuttonTap”,
事件:“点击”,
代表:“#我的按钮”
}
]
},
onMybuttonTap:函数(按钮、e、选项){
Ext.device.Camera.capture({
资料来源:“摄像机”,
目标:“文件”,
成功:函数(url){
this.firevent('change',this,url);
},
失败:函数(){
Ext.Msg.alert('错误','获取图片时出错');
},
范围:本
});
}
});
为什么没有人对我的问题发表评论?我的问题有什么问题吗???欢迎任何更正和建议。请重新措辞我的问题,希望它能清楚地表达我的表情。请为这个问题添加赏金,谢谢你的帮助。嗨,弗拉德,谢谢你的回答。我已经更新了我的问题,以澄清我想要什么。请看一看,谢谢。看看这个。插件通常作为窗口提供。{clobberValue}
。嗨,弗拉德,很高兴在那里看到官方代码!然而,在编写代码之前,我认为应该有一些步骤来连接Sencha Touch和Cordova的pulgin,否则我们无法获得相机的参考。例如,为了使用cordova插件,用户必须将插件文件路径添加到app.js或app.json或其他地方。这就是我特别想要的部分。希望我的解释对你有意义。谢谢你的帮助。指南应该是完整的。这里还描述了一个问题:嗨,弗拉德,我看了你的答案,这个答案比我的更详细,所以我决定把你的帖子作为答案。非常感谢。