【发布时间】:2021-05-01 19:41:07
【问题描述】:
我有这样的数据 - phone 对象的键可以是“mobile”、“home”...
contacts[
11:{
name: "Mr Blobby"
phone: {
mobile: "07123 456789",
home: "0201 2345 6789"
}
...
}
...{}
显示它(cRud)很容易:
<div v-for="contact in contacts" :key="contact.id" :contact="contact">
<div v-for="(phone, type) in contact.phone" :key="type" :phone="phone">
<b>{{ type }}</b>
<h2>{{ phone }}</h2>
</div>
</div>
但是如何使用 select 和 v-model (CrUd) 专门绑定键(移动/家庭...)?
<div v-for="(phone, index) in contact.phone" :key="phone">
<input type="tel" v-model.trim="contact.phone[index]" />
<select v-model="???">
<option value="mobile">Mobile</option>
option value="home">Home</option>
</select>
</div>
【问题讨论】:
标签: vuejs3