赞
踩
前端代码
- <div id="app">
- <select class="form-control con1" @change="changeProduct($event)">
- <option value="" disabled selected>请选择</option>
- <option v-for="item in list" :value="item">{{item}}</option>
- </select>
- </div>
js代码
- new Vue({
- el:"#app",
- data:{
- list:[]
- },
- methods: {
- changeProduct(event){
- console.log(event.target.value)
- }
- }
- })
动态添加option
- var arr = [1,2,3,4,5];
- for(var i=0; i < arr.length; i++){
- this.list.push(arr[i]);
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。