zoukankan      html  css  js  c++  java
  • vue实现下拉框

    <template>
        <div>
            <li>
      <div class="por">
        <div class="selectBox" style=" 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;  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>
  • 相关阅读:
    HTML: vertical algin Big/small div in same row (bootstrap)
    unix时间转换
    chrome工具分析
    DNF 包管理器
    安装nodejs
    location属性解释
    angular深入理解途径
    ui-router与ngRoute
    angular $location服务获取url
    Python文件操作
  • 原文地址:https://www.cnblogs.com/mzj143/p/12989970.html
Copyright © 2011-2022 走看看