首页 > 编程语言 > 详细

VUE element ui根据数组生成多个互不干扰的下拉菜单并获取对应参数

时间:2020-07-27 16:46:30      阅读:86      评论:0      收藏:0      [点我收藏+]

直接放效果图和代码
效果图:
  1.默认初始效果

技术分享图片

  2.选择后效果

技术分享图片

代码

<template>
  <basic-container>
    <h2>VUE element ui根据数组生成多个互不干扰的下拉菜单并获取对应参数</h2>
      <el-row>
          <el-col>
            <el-button @click="aaa">输出下拉数组</el-button>
          </el-col>
      </el-row>

      <el-row :gutter="12">
        <el-col :span="6" v-for="(item,index) in imgList" style="padding-top: 10px;">
          <el-card style="width: 100%; height: 280px;" :body-style="{ padding: ‘0px‘ ,width:‘100%‘,height:‘100%‘, display: ‘flex‘,cursor:‘pointer‘}"
            shadow="hover">
            <div style="position: relative; width: 100%;" class="check_box">
              <el-dropdown @command="sumTypeCkeck" @visible-change="set_index(index)" style="position: absolute;right: 10px; top: 5px; z-index: 1;">
                <span class="el-dropdown-link" style="color: #FFFFFF;">
                  {{sumType[index]}}<i class="el-icon-arrow-down el-icon--right"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item v-for="(item,index) in sumTypeArray[index]" v-text="item" :command="item"></el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
              <el-image :src="item.img" onerror="this.style.display=‘none‘" style="max-height: 100%;max-width: 100%;left: 50%;top: 50%;transform: translate(-50%,-50%)">
              </el-image>
              <div style="font-size: 16px;position: absolute;bottom: 0; background-color: rgba(150, 150, 150, 0.35); height: 30px; width: 100%; text-align: center; line-height: 30px;color: yellow;">{{item.title}}</div>
            </div>
          </el-card>
        </el-col>
      </el-row>
  </basic-container>
</template>

<script>
  import ThreeDmodel from ../../components/4D/3Dmodel.vue
  export default {
    components: {
      ThreeDmodel
    },
    data() {
      return {
        imgList: [],        //显示墙面的数组
        index:0,           //第几个下拉框
        sumTypeArray: [[0,1, 2, 3, 4, 5],[0,9,10],[0,110,120],[0,119,911],[0,5,4],[0,3,8],[0,41,514]],//下拉参数值
        sumType: [],        //选中(默认)值
      };
    },
    mounted() {
      for (var i = 0; i < 6; i++) {
        this.imgList.push({
          title: i + 1 + ,
          img: http://192.168.10.67:8000/media/77/test/images/ABC%E5%A1%94%E6%A5%BC%E7%AB%8B%E9%9D%A220120824_t3_2/glass/C-LM-02-11-20.png
        })
      }
      for(var i=0;i<this.imgList.length;i++){
        this.sumType.push(0)
      }
    },
    methods: {
      sumTypeCkeck(type) {
        this.sumType[this.index] = type
        this.sumType=[...this.sumType]//ES6拓展运算符生成新的props对象
        // console.log(type)
        // console.log(this.index)
      },
      set_index(index) {
        this.index = index
      },
      aaa(){
        console.log(this.sumType)
      },
    },
  }
</script>

<style>
</style>

 

VUE element ui根据数组生成多个互不干扰的下拉菜单并获取对应参数

原文:https://www.cnblogs.com/ren17/p/13385027.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!