【问题标题】:Vue :state, what is this?Vue:状态,这是什么?
【发布时间】:2020-09-24 06:25:37
【问题描述】:
【问题讨论】:
标签:
vue.js
bootstrap-vue
vuelidate
【解决方案1】:
如docs中提到的:
状态 - 布尔值 - null
控制组件的验证状态外观。 'true' 表示有效,'false' 表示无效',或 'null' 表示无验证状态
要动态绑定这个属性,我们可以使用v-bind 指令,例如:
<b-form-select
id="example-input-2"
v-bind:state="validateState('food')"
></b-form-select>
或者我们可以使用v-bind:state 的简写形式,即:state,例如:
<b-form-select
id="example-input-2"
:state="validateState('food')"
></b-form-select>
【解决方案2】:
“状态”不是属性,而是属性,子组件中的属性之一,它期望您从主 vue 文件传递或称为“父组件”的布尔值
这里使用的属性是“v-bind”或简写的“:”,然后传递属性“state”因此是“:state”