Vue监听select标签change事件
- Html
<select id="country" v-model="country" @change="changeCountry" >
<option value="">请选择</option>
<option v-for="option in countries" v-bind:key="option.key" v-bind:value="option.value">
{{ option.text }}
</option>
</select>
- JavaScript
data () {
return {
countries: [{
'key': 'china',
'value': 'china',
'text': '中国'
}, {
'key': 'america',
'value': 'america',
'text': '美国'
}],
country: ''
}
},
methods: {
changeCountry () {
console.log(this.country)
}
}
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/12/vue-listen-for-select-tag-change-event/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
THE END
0
二维码
打赏
海报
Vue监听select标签change事件
Html
<select id="country" v-model="country" @change="changeCountry" >
<option value="">请选……
文章目录
关闭
共有 0 条评论