我正在创建自己的原理图。该原理图将负责使用一些代码来创建组件(容器)。该组件的模板将包含其他一些组件。该组件之一将是横幅组件,它将是可选的。此横幅将显示将被翻译成其他语言的文本,因此我还应要求用户提供(默认)翻译文本,如果横幅将包含在组件中。 这是此模板的示例:
name @ dasherize .component.html.template:
<% if (includeBanner) { %>
<app-banner [title]="'<%= translationModuleKey %>.banner.title' | translate"
[description]="'<%= translationModuleKey %>.banner.description' | translate">
</app-banner>
<% } %>
<app-other-component>
</app-other-component>
这是我的schema.json:
{
"$schema": "http://json-schema.org/schema",
"id": "MySchematics",
"title": "My schematics",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the container",
"x-prompt": "Container name"
},
"includeBanner": {
"type": "boolean",
"description": "Include banner",
"default": "true",
"x-prompt": "Include banner"
},
"bannerTitle": {
"type": "string",
"description": "Banner title",
"x-prompt": "Banner title"
},
"bannerDescription": {
"type": "string",
"description": "Banner description",
"x-prompt": "Banner description"
},
"translationModuleKey": {
"type": "string",
"description": "Root key for translations"
}
},
"required": [
"name", "includeBanner", "bannerTitle", "bannerDescription"
]
}
我的问题是,当用户将includeBanner设置为true时,字段必须为bannerTitle和bannerDescription,并且如果未提供这些属性,则应该显示提示,但是如果includeBanner为false,则不需要如果未提供这些属性,则不应显示提示来填充这些属性。 知道如何实现吗?