vue-select 绑定v-model 问题

<template>
  <div>
  <ul >
    <li v-for="(item,index) in data" :key="index">
     <div>{{item.name}}</div>
      <el-select v-model="item.value" placeholder="请选择" >
          <el-option
            v-for="(ee,index) in item.sclist"
            :key="index"
            :label="ee.label"
            :value="{value:ee.value,label:ee.label}">
          </el-option>
      </el-select>
  </li>

        </ul>
  </div>
</template>

<script>
export default {
  data () {
    return {
      interfaceData: [{mingzi: 'zhangsan', vendorID: 'A2'}, {mingzi: 'zhangsan', vendorID: ''}],
      data: [{id: 10,
        name: 'zhangsan',
        value: '',
        sclist: [{
          key: 1,
          version: 'A1',
          label: 'A1'
        }, {
          key: 2,
          version: 'A2',
          label: 'A2'
        }]},
      {id: 13,
        name: 'lisst',
        value: '',
        sclist: [{
          key: 1,
          value: 'B1',
          label: 'B1'
        }, {
          key: 2,
          value: 'B2',
          label: 'B2'
        }]}]
    }
  },
  mounted () {
    console.log(this.data)
    /* this.data.forEach(item=>if(item.name==="zhangsan"){
      item.value='A2';
    }) */
    for (let index = 0; index < this.data.length; index++) {
      if (this.data[index].name === 'zhangsan') {
        this.data[index].value = 'A2'
      }
    }
  },
  methods: {

  }
}
</script>

<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

 

展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读