Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

仅仅用type无法决定到组件,是否可以增加format #4

Open
smuki opened this issue Feb 9, 2021 · 1 comment
Open

仅仅用type无法决定到组件,是否可以增加format #4

smuki opened this issue Feb 9, 2021 · 1 comment

Comments

@smuki
Copy link

smuki commented Feb 9, 2021

当前字段对应组件是用type,
比如,假设 是/否对应到是checkbox,
但有时我也可以用radio来做到是/否,
或者用select 也可以做到 是/否

所以单单单用type决定用那个组件是不太够用单
假设加上 format 就可以灵活来很多来.

@dongls
Copy link
Owner

dongls commented Feb 9, 2021

type字段是用来确定某一字段的字段类型的,例如:
radio - 单选 , checkbox - 多选 ,select - 下拉选择

从设计角度来说,xform倾向于每一种字段类型都是提供某一特定功能的最小字段类型,而不是复合型的。

对于上面提到的需求,有以下几种解决方案:

  1. 注册一种新的字段类型满足上述需求,可将相关属性存储在XField.attributes中
  2. 通过提供名为type_[type]的slot在组件中定制某一类型的字段,例如:
<xform-builder>
  <template #type_text>type为text的字段都将显示这段文字</template>
</xform-builder>
  1. 通过提供名为name_[name]的slot在组件中定制某一特定字段,例如:
<xform-builder>
  <template #name_address>name值为address的字段将显示这段文字</template>
</xform-builder>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants