vue el-dropdown使用

模板代码:

<template>
  <div>
    <el-row>     
      <el-col :span="4">
        <span>汇总方式:</span>
        <el-dropdown @command="sumTypeCkeck">
          <el-button type="primary">
            {{sumType}}<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown"  >
            <el-dropdown-item v-for="(item,index) in sumTypeArray"
                              v-text="item"
                              :command="item"
            ></el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-col>
    </el-row>
  </div>
</template>

事件:@command 触发点击的时候,控件会将你点击的内容传递到方法内。
vue代码:

<script>
  export default {
    name: 'CustomIndexOperation',
    data(){
      return{        
        sumTypeArray:['汇总方法','计算方式'],
        sumType:"汇总方式",
        formulaArea:''   //公式的文本框
      }
    },
    methods:{
      sumTypeCkeck(type){  // 下拉列表的点击事件
        this.sumType=type
      }
  }
  }
</script>

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/u012976879/article/details/83896854
今日推荐