element-ui 的組件el-select的 value-key 作為 value 唯一標(biāo)識(shí)的鍵名,綁定值為對(duì)象類型時(shí)必填
用法如下:
<el-select placeholder="請(qǐng)輸入抄送人" v-model="recipients" multiple filterable remote
:remote-method="remoteMethod" :loading="loading" value-key="id" :default-first-option="true">
<el-option
v-for="item in userList"
:key="item.id"
:label="item.userName"
:value="item">
</el-option>
</el-select>
這里標(biāo)注下注意點(diǎn):
- 綁定值為對(duì)象類型, value-key必填
- 例子中id為對(duì)象item的屬性
- 如果想在保存后,編輯頁(yè)面時(shí),在select上顯示數(shù)據(jù),
需要在頁(yè)面初始化時(shí),把recipients賦值給userList。