1 回答
TA贡献1765条经验 获得超5个赞
但是,您必须使用==或===代替=,如果我们computed在此处使用归档作为placeholder
<select class="form-control" id="platform" v-model="platform">
<option v-for="option in options" :value="option.value">{{ option.text }}</option>
</select>
<input type="text" class="form-control" :placeholder="placeholder">
data() {
return {
platform: '',
options: [
{ text: 'PSN', value: 'psn', placeholder: 'Enter PSN ID' },
{ text: 'Xbox Live', value: 'xbl', placeholder: 'Enter Origin ID' },
{ text: 'Origin', value: 'origin', placeholder: 'Enter Xbox Live Gamertag' }
]
}
},
computed: {
placeholder() {
let selected = this.options.find(o => o.value === this.platform)
return selected ? selected.placeholder : ''
}
}
在本例中,placeholder将自动生成。
添加回答
举报