0

同じ sencha touch アプリケーション内の別の JS ファイル内の JavaScript ファイルで宣言されたオブジェクトにアクセスするにはどうすればよいですか?? Sencha Touch が得意な方からのヘルプは大歓迎です。

前もって感謝します。

4

2 に答える 2

0

私は Sensa Touch には詳しくありませんが、一般的に JavaScript では、グローバル オブジェクトを使用してそれらを共有するか、関数間でオブジェクト参照を渡すことができます (同じ JS ファイル内にあるかどうかに関係なく)。

于 2011-01-06T14:13:17.713 に答える
0

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

于 2011-01-14T20:59:51.940 に答える