如何在 Sencha Touch View 中使用 JS?
Ext.define('project.view.viewexample', {
extend: 'Ext.Panel',
xtype: 'asd',
config: {
styleHtmlContent: true,
scrollabe: 'vertical',
title: 'TITLE!',
Html: '<html>code and also JS?'
}
});
我有 htmlcode,其中包括 jscode(在脚本标签内)。在这件事上使用它似乎不起作用,对吗?我也尝试过使用 tpl,但它没有改变任何东西。
有人知道如何正确使用JS吗?一个更好的选择是在 Controller 中使用它,但在这种情况下我不知道如何传递数据。
编辑: 我已经更接近我认为的解决方案了。下面的代码显然是错误的,但也许有人可以看到我做错了什么:
Ext.define('projext.view.viewexample', {
extend: 'Ext.Panel',
xtype: 'gps',
config: {
styleHtmlContent: true,
scrollabe: 'vertical',
title: 'GPS',
tpl: 'Här var det GPS'
},
constructor: function() {
this.getPosition();
},
getPosition: function() {
var geo = Ext.create('Ext.util.Geolocation', {
autoUpdate: false,
listeners: {
locationupdate: function(geo) {
alert('New latitude: ' + geo.getLatitude());
},
locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
if(bTimeout){
alert('Timeout occurred.');
} else {
alert('Error occurred.');
}
}
}
});
geo.updateLocation();
}
});
最佳答案
html
配置需要小写。
Ext.define('project.view.viewexample', {
extend: 'Ext.Panel',
styleHtmlContent: true,
scrollabe: 'vertical',
title: 'TITLE!',
html: 'define your html'
});
关于javascript - Sencha Touch 2 - 将 javascript 添加到 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15551824/