为什么视图的别名定义为“widget.myxtype”?
我想知道:为什么我们定义的新小部件的别名总是定义为“widget.myxtype” - “小部件”的意义是什么?
I was wondering: Why is the alias of new widgets we define always defined as "widget.myxtype" - what is the significance of the "widget" in that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Alias属性是ExtJs4中新引入的,它是以前版本中“xtype”的替代品。alias中指定的“widget”确实有我能想到的两个意义:
您可以利用创建小部件的简写。例如,如果您有一个名为 widget.myview 的小部件,则可以按如下方式创建它的实例:
如果别名中没有添加“widget”前缀,则只能通过以下方式实例化:
另外,还可以使用 create 方法创建已使用 Ext.define() 定义的任何类的实例。
当您添加“widget”前缀时,您确定它们会处理 UI。这有助于更好地理解和阅读代码(当您看到 Ext.widget('abc') 时,您知道它是一个窗口、按钮或某些 UI 组件)。
更新:
alias 属性由非 UI 组件的其他类使用。但是,您只会看到 UI 组件的“widget”,因此将其表示为视图或 UI(这就是为什么它们只有 widget 的简写)。其他 ExtJS 类也有别名。例如,所有代理类都有“proxy”前缀。但目前,“代理”前缀的唯一意义是可读性。
Alias property was newly introduced in ExtJs4 and is a substitute for "xtype" in previous versions.The "widget" specified in alias do have two significance that I can think of:
You can make use of the shorthand to create a widget. For example, if you have a widget named widget.myview, you can create an instance of it as follows:
If you don't prefix the "widget" in alias, you can instantiate only through:
Also, the create method can be used to create an instance of any class that has been defined using Ext.define().
when you prefix "widget", you are sure they will deal with UI. This helps in better understanding and reading of the code (when you see Ext.widget('abc'), you know its a window,button or some UI component).
Update:
alias property is used by other classes that are not UI component. But, you will see "widget" for UI components only hence denoting it as an view or UI (that is why they have the shorthand for widget alone). Other ExtJS classes also have alias. For example, all the Proxy classes will have "proxy" prefix. But for now, the only significance for the "proxy" prefix is readability.
我认为这是一种命名空间:您还可以为代理、读者和作者定义别名,分别需要以“代理”、“读者”为前缀。和“作家”。 :
然后您可以通过以下方式引用它们:
I think it's a kind of namespace : you can also define aliases for proxies, readers and writers, which respectively need to be prefixed with 'proxy.', 'reader.' and 'writer.' :
Then you can reference them with :