zoukankan      html  css  js  c++  java
  • vue操作select获取option值

    如何实时的获取你选中的值 只用@change件事
    @change="changeProduct($event)" 动态传递参数
    vue操作select获取option的ID值

    如果select的v-model(value)与option绑定的value值一致。
    那么就会显示option中的值 {{item.title}}-->

    <div id="app">
           <select  class="fl" v-model="ProductActive"  @change="changeProduct($event)" >
                <option v-for="(item,index) in productList" :key="index" :value='item.id'>{{item.title}}</option>  
           </select>  
      </div>
    data:{
            productList:[{id:1,title:"北京"},{id:2,title:"上海"},{id:3,title:"广州"},{id:4,title:"四川"}],
            ProductActive:"1",//获取被选中的value值 默认选中的是1(北京)
         },
                    
      methods: {
               changeProduct(event) {
                 this.ProductActive = event.target.value; //获取option对应的value值
                 console.log("你选中了",this.ProductActive)
               },
           }

  • 相关阅读:
    Redis-持久化
    Redis-Sort命令
    Redis-ZSet常用命令
    Redis-Hash
    Redis-Set常用命令
    Redis-List常用命令
    Redis-String常用命令
    访问控制
    c++之旅:多态
    c++之旅:类型的强制转换
  • 原文地址:https://www.cnblogs.com/IwishIcould/p/11360059.html
Copyright © 2011-2022 走看看