简体   繁体   English

如何在视图中使用Ext JS控制器?

[英]How can I use an Ext JS controller with a view?

I do plan on using an application, but I also want to be able to use standalone view and controller groupings. 我计划使用应用程序,但我也希望能够使用独立视图和控制器分组。 The only way I have found to use a controller is by listing it in the "controllers" config of an app. 我发现使用控制器的唯一方法是将其列在应用程序的“控制器”配置中。 Is this the only way? 这是唯一的方法吗?

A Controller does not have to be listed in an app's controllers config for it to work. 控制器不必在应用程序的controllers配置中列出,以使其工作。 You can use getController (also available on the global application) to create an instance of any controller. 您可以使用getController (也可在全局应用程序中使用)来创建任何控制器的实例。 If you create the controller in some other way (using new, for example) you will be responsible for initializing it and making sure it has a reference to the global application. 如果您以其他方式创建控制器(例如,使用new),您将负责初始化它并确保它具有对全局应用程序的引用。 If it doesn't have a reference to the application, the controller methods that delegate to the application won't work. 如果它没有对应用程序的引用,则委派给应用程序的控制器方法将不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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