我正在使用https://bootstrap-vue.org/docs/reference/validation#vuelidate,并且遇到了
:state
作为vue属性。
我没有在文档中找到任何东西,我很困惑。它来自哪里,它是做什么的?实际上似乎我需要使用它来验证输入字段。但我宁愿使用@blur代替state,但无法正常工作。
如docs中所述:
状态-布尔值-空
控制组件的验证状态外观。 “ 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>
“状态”是子组件中的属性之一,它期望从主vue文件传递或被称为“父组件”的布尔值。