[英]how to use conditional if else statement in v-decorator of an ant-design selection
I have a Vue app with select option that using ant-design selection我有一个带有选择选项的 Vue 应用程序,该应用程序使用 ant-design selection
this is my html structure :这是我的 html 结构:
<a-select
v-decorator="[
'race',
{
initialValue: profile.race,
rules: [
{
required: true, message: 'Race is required.'
},
]
},
]"
>
<a-select-option value=1>Malay</a-select-option>
<a-select-option value=2>Chinese</a-select-option>
<a-select-option value=3>Indian</a-select-option>
<a-select-option value=4>Others</a-select-option>
</a-select>
where the profile.race bring integer value.其中 profile.race 带来整数值。 for showing the race.
用于展示比赛。 but in the default view, it's showing just integer instead of the words.
但在默认视图中,它只显示整数而不是单词。
I want in default display it's showing the race word, not the integer value.我想在默认显示中显示种族词,而不是整数值。 I also have using
defaultValue
, but it's just the same with initialValue
how can I play with the conditional statement in v-decorator
?我也使用了
defaultValue
,但它与initialValue
相同,我如何在v-decorator
使用条件语句? or anything I can do to solve this problem?或者我能做些什么来解决这个问题?
this is the code that i have tried but still did not work.这是我尝试过但仍然无效的代码。
initialValue: '\''+profile.race+'\'',
this will bring '1' as value but still it showing '1' instead of the race.这将带来“1”作为价值,但它仍然显示“1”而不是比赛。 but when i'm using
但是当我使用
initialValue: '1'
, it's work. initialValue: '1'
,它的工作。 how can it be?怎么会这样?
The initialValue
need to be a string value in order to work as expected initialValue
需要是一个字符串值才能按预期工作
initialValue: profile.race + ''
This is the working example: https://codesandbox.io/s/vue-template-sokxn这是工作示例: https : //codesandbox.io/s/vue-template-sokxn
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.