The value bound to v-model in el-select and how to echo it
1. When v-model is bound to a certain value, there is nothing wrong with it, and the corresponding value can be echoed
2. When other attributes in options need to be used, when v-model binding a single value cannot solve the demand, it needs to be bound into an object
<el-select v-model="selected" value-key="id" > <el-option value="" label="请选择" /> <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item" /> </el-select>
The value corresponding to :value is the value bound to the v-model. The item is an object at this time , so it will be very convenient to fetch and select other data in this object.
Echo: When echoing , the value bound to v-model must also be an object, that is, selected must be an object , and this object must contain the attribute bound in value-key (same name)
The attribute name bound in the value-ley corresponds to the attribute name in the key, and the {value-key bound attribute value = the value of the object bound in the key} in the echo object will be echoed back to the success value -The name in the key must be consistent with the key value
selected:{ id: response.result.id } //There must be an id attribute in the object, and the presence of other attributes will not affect the echo //This can be echoed