美文网首页
关于下拉选择框的使用

关于下拉选择框的使用

作者: inyourface | 来源:发表于2021-04-15 16:12 被阅读0次

主要是选择值问题

上代码:

<el-select v-model="selectCountry" placeholder="请选择" @change="selectValue()">
                  <el-option
                    v-for="item in countryData"
                    :key="item.abbreviation"
                    :label="item.country"
                    :value="item.country">
                  </el-option>
                </el-select>

1.通过el-select的change事件会在选中值变化时触发,而选择的值存放在 v-model="selectCountry"中
2.在methods中,change的绑定事件进行获取

selectValue() {
      console.log(this.selectCountry)//打印输出的是  :value="item.country"的值
    },

3.这是我的数据

countryData:[
        {"country":"Afghanistan","abbreviation":"AFG"},
        {"country":"Albania","abbreviation":"ALB"},
        {"country":"Algeria","abbreviation":"DZA"},
        {"country":"All Qatar","abbreviation":"QAT"},
        {"country":"angola","abbreviation":"AGO"},
    ]

相关文章

网友评论

      本文标题:关于下拉选择框的使用

      本文链接:https://www.haomeiwen.com/subject/hhadlltx.html