美文网首页程序员
element-ui select 默认选中

element-ui select 默认选中

作者: ing1023 | 来源:发表于2018-11-29 14:36 被阅读0次
    v-model的值为当前被选中的el-option的 label 属性值
    
    <template>
      <el-select v-model="select" placeholder="请选择">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
    </template>
     
    <script>
      export default {
        data() {
          return {
            options: [{
              value: '选项1',
              label: '黄金糕'
            }, {
              value: '选项2',
              label: '双皮奶'
            }, {
              value: '选项3',
              label: '蚵仔煎'
            }, {
              value: '选项4',
              label: '龙须面'
            }, {
              value: '选项5',
              label: '北京烤鸭'
            }],
            select: ' '  // 选取默认值在里面就可以了,比如:  select:"双皮奶";
          }
        }
      }
    

    相关文章

      网友评论

        本文标题:element-ui select 默认选中

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