今天在設計一個標籤(採用的是Select 選擇器中的標籤那一個)時,從後臺返回了數據,但是在輸入值時,沒有對回顯的值進行過濾匹配,通過查看官方文檔,解決了這個問題。記在這裏方便以後查看。
<a-form-item label='標籤' v-bind="formItemLayout">
<a-select
mode="tags"
:allowClear="true"
:filterOption="filterOption"
style="width: 100%"
v-decorator="['tag',{rules: [{ required: true, message: '請選擇標籤' }]}]">
<a-select-option v-for="t in tags" :key="t.id.toString()">{{t.tagName}}</a-select-option>
</a-select>
</a-form-item>
methods中:
filterOption(input, option) {
return (
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
);
},
其中對於過濾起作用的是filterOption
官網上對其的解釋: