APl*_*ace 5 drop-down-menu vue-component vue-select vuejs3
假设我有一个数据 - news: {id:3, name:"book", author:'author'}。并选择与options: {id: 1, book: "book1"}, {id: 2, book: "book2"} .
现在我想用 news.id 和 news.book 进行 v-bind 选项 有没有办法做到这一点或准备好组件?
<select v-model="selected">
<option v-for="option in options" :value="option.id">
{{ option.name}}
</option>
</select>
Run Code Online (Sandbox Code Playgroud)
data() {
return {
selected: 1,
options: [
{ name: 'book1', id: 1 },
{ name: 'book2', id: 2 },
{ name: 'book3', id: 3 }
]
}
Run Code Online (Sandbox Code Playgroud)