将初始参数传递给 ExtJS 4 应用程序
我对 ExtJS 和 javascript 框架绝对是全新的,这是一个非常简单的问题,但我似乎找不到一个例子。
我试图找出如何简单地将初始参数从托管 html 页面传递到 ExtJS 4 应用程序 - ExtJS 4 相当于应用程序托管 html 页面中这条非常简陋的行:
var myapp = new MyApp({param1:'value1', param2:'value2'});
我看到的所有内容:在线示例并不当应用程序启动时,最初不会将参数传递给应用程序。这是不是正确的想法或什么......?
I am absolutely brand new to ExtJS and javascript frameworks, and this is a dead simple question but I just can't seem to find an example.
I am trying to find out how I should simply pass initial arguments from the hosting html page to an ExtJS 4 application - what is the ExtJS 4 equivalent of this very humble line in the app's hosting html page:
var myapp = new MyApp({param1:'value1', param2:'value2'});
Everything I see re: examples online doesn't pass arguments initially to the application when it starts up. Is that just not the right idea or something..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通常在页面上创建全局变量,然后在js中使用它们。
就像:
然后我直接在需要的地方使用它们。
也许将所有这些变量收集到一个全局对象中是一个好主意,例如:
这样您将拥有全局数据的一个入口点。
这就是我这样做的方式,很高兴听到其他人是如何做的。
I usually create global variables on the page and then just use them in js.
Something like:
Then I use them directly where I need.
Perhaps it's a good idea to collect all this variables into one global object, like:
So you'll have one entry point to your global data.
It's just the way I do this, nice to hear how other do.
您可以在 app/Configuration.js 中使用单例配置文件,在其中定义所有变量、用于全局访问的 url:
您现在需要在 Application.js 文件中需要此文件:
需要 : [ 'myApp.Configuration'] 提前加载它以便在其他文件中使用,例如:
myApp.Configuration.urls.actionURL
所以,我想对于您的应用程序范围设置来说是非常干净的解决方案。
干杯!
You can use a singleton Configuration file in app/Configuration.js , where u define all the variables , urls for global access :
you now need to require this file in Application.js file as
requires : [ 'myApp.Configuration'] to load it in advance for usage in other files like:
myApp.Configuration.urls.actionURL
So, i guess very clean solution for your application wide settings.
Cheers!