Enyo,如何有一个以上的控制锅

enyo, how to have pans with more then one control

本文关键字:控制 一个以 Enyo      更新时间:2023-09-26

我只是学习enyo,并做了一个简单的程序使用锅。现在每个锅都是一个按钮。有没有办法在每个锅里有一堆控件,而不是一个?在我的代码的例子中,第一个锅有一个按钮,但它可以有3个按钮吗?我的代码

enyo.kind({
    name: "MyApps.MainApp",
    kind: enyo.VFlexBox,
    components: [
       {kind: "PageHeader", content: "Template"},
       {kind: "Pane", transitionKind: "enyo.transitions.LeftRightFlyin", components: [
           {kind: "Button", name:"butA", caption: "Pane A", onclick: "btnClickA"},
           {kind: "Button", name:"butB",caption: "Pane B", onclick: "btnClickB"}
       ]}
   ],
   /// code to switch pans
   btnClickA: function() {
       this.$.pane.selectView(this.$.butB);
   },
   btnClickB: function() {
       this.$.pane.selectView(this.$.butA);//k
   },
});

你当然可以。窗格为其组件数组中的每个对象创建一个视图,但这些组件可以包含子组件。例如,假设您想在一个窗格中创建视图,每个视图有两个按钮,您可以使用这样的代码:

...
{kind:enyo.Pane, components:[
    {kind:enyo.VFlexBox, name:"View1", components:[
        {kind:enyo.PageHeader, content:"Pane One"},
        {kind:enyo.Button, caption:"Button One"},
        {kind:enyo.Button, caption:"Button Two"},
    ]},
    {kind:enyo.VFlexBox, name:"View2", components:[
        {kind:enyo.PageHeader, content:"View Two"},
        {kind:enyo.Button, caption:"Button One"},
        {kind:enyo.Button, caption:"Button Two"},
    ]},
]},
....
相关文章: