我需要一个应用程序来显示在运行时创建的按钮。原因是我将从服务中获取信息以查看我需要多少按钮。
当前程序正在运行,但没有显示任何按钮。
我正在尝试使用工具栏并在创建函数中设置控件属性。程序运行正常,但我的工具栏没有按钮?有没有办法做到这一点?
代码:
// Trying to create buttons at run time
name: "MyApps.MainApp",
kind: enyo.VFlexBox,
components: [
{kind: "PageHeader", content: "Template"},
{kind: "Toolbar", name: "tabsted"},
{name: "feedUrl", kind: "Input", flex: 1},
{kind: "HtmlContent", name: "comments", content: "hello world <br> and another lin"},
{name:"curValue", content:("Sample Text \r\n and more")},
{kind: "Button", caption: "Action", onclick: "btnClick"},
],
// this gets called first ha
create: function()
{
this.inherited(arguments);
this.$.tabsted.components= [
{caption: "a"},
{caption: "b"},
{caption: "c"}
];
this.LoadCommments();
},
LoadCommments: function()
{
this.$.comments.content="fred";
},
// called when button is clicked
btnClick: function()
{
this.$.curValue.setContent("Put some text here"); // handle the button click
}
};