渲染构件
我们可以通过使用小部件的id
引用它来呈现该小部件
要在应用程序中的任意位置呈现构件widget_languages
,可以使用简单语法:
{
"component": "widget",
"id": "widget_languages"
}
小组件也可用于呈现复杂的项目,例如,我想呈现每个文件的参与者列表。
在这里,构件可以构造为:
const widgetJSON = {
component: "div",
id: "file_contributors",
items: [ // adding components to the widget
{
component: "div",
items: [
{
component: "icon",
icon: "file"
},
{
component: "label",
label: "@fileName"
}
]
},
{
component: "list",
data: "@contributors",
itemConfig: {
component: "label"
}
}
]
},
现在,为了呈现每个文件的参与者列表,我们将该列表编写为:
const listJSON = {
component: "list"
data: "@files"
itemConfig: {
component: "widget",
id: "file_contributors"
}
}
此处@files
是包含字段的文件对象列表
- fileName: string
- contributors: Array<String>
recommendation-more-help
11125c99-e1a1-4369-b5d7-fb3098b9b178