码迷,mamicode.com
首页 > 其他好文 > 详细

vue实现下拉框

时间:2020-05-29 23:22:02      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:color   top   title   sel   lock   datalist   stop   list   input   

<template>
    <div>
        <li>
  <div class="por">
    <div class="selectBox" style="width: 400px;">
      <div class="selectBox_show" v-on:click.stop="arrowDown">
        <i class="icon icon_arrowDown"></i>
        <p title="请选择">{{unitName}}</p>
        <input type="hidden" name="unit" v-model="unitModel">
      </div>
      <div class="selectBox_list" v-show="isShowSelect"
           style="max-height: 240px; width: 398px; display: block;">
        <div class="selectBox_listLi" v-for="(item, index) in dataList"
             @click.stop="select(item, index)">{{item.value}}
        </div>
      </div>
    </div>
  </div>
</li>
    </div>
</template>

<script type="text/ecmascript-6">
  export default {
    data() {
      return {
        isShowSelect: false,
        dataList: [
          {key: -1, value: "请选择"},
          {key: 0, value: "苹果"},
          {key: 1, value: "香蕉"},
          {key: 2, value: "荔枝"},
          {key: 3, value: "火龙果"},
          {key: 4, value: "橘子"},
          {key: 5, value: "黄瓜"}
        ],
        unitName:请选择
      }
    },
    methods: {
      arrowDown() {
        this.isShowSelect = !this.isShowSelect;
      },
      select(item, index) {
        this.isShowSelect = false;
        console.log(item);
        console.log(index);
        this.unitModel = index;
        this.unitName = item.value;
      }
    }
  };
</script>


<style scoped>

</style>

 

vue实现下拉框

标签:color   top   title   sel   lock   datalist   stop   list   input   

原文地址:https://www.cnblogs.com/mzj143/p/12989970.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!