显示是列表的value,保存时是保存key
双向绑定也是key(id),在select标签下显示value,定义遍历的list,index,key,value
<a-form-item
label="type"
:labelCol="{span: 7, offset: 0}"
:wrapperCol="{span: 13, offset: 0}"
>
<a-select
:allowClear="true"
showSearch
placeholder="请选择"
:filterOption="filterOption"
@change="onChange"
v-decorator="['typeId', {rules: [{ required: true, message: '不能为空'}]}]"
>
<a-select-option
v-for="(item,index) in typeList"
:key="index"
:value="item.typeId"
>{{item.name}}</a-select-option>
</a-select>
</a-form-item>
转换大小写
filterOption(input, option) {
return option.componentOptions.children[0].text.indexOf(input) >= 0
},
getTypeList() {
var that = this;
var params = {};
that.$get("url", params).then(r => {
var data = r.data;
that.typeList = data;
});
},
选择不同的value更换key,onchange控制
onChange(value, label, extra) {
this.paramsData.typeId = label[0];
},