简体   繁体   中英

How can we access objects declared in a javascript file in another file in a sencha touch application?

How can we access objects declared in a javascript file in another JS file in the same sencha touch application?? Help from anyone good in Sencha Touch is highly appreciated.

Thanks in advance.

我不熟悉Sensa Touch,但通常在JavaScript中,您可以使用全局对象共享它们,也可以在函数之间传递对象引用(无论是否在同一JS文件中)。

The fact that the Javascript is in a different file isn't really a huge matter. It's more a matter of understanding scope & global variables etc.

If you create a variable in the global scope of one file:

var hello = 'hello';

Then this is of course available in another file:

alert(hello + ' world');

(Although you'd want to get the order correct when you import those files into the HTML document)

All that said, global variables are normally advised against, and Sencha Touch provides a way to namespace variables too: see Ext.namespace in http://dev.sencha.com/deploy/touch/docs/?class=Ext

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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