Elementui - 下拉框(el-dropdown-menu组件)的使用方法

Elementui - 下拉框(el-dropdown-menu组件)的使用方法

官方文档

简单样式—此为指令事件,具体效果请看文档
<el-dropdown @command="handleCommand">
  <span class="el-dropdown-link">
    下拉菜单<i class="el-icon-arrow-down el-icon--right">i>
  span>
  <el-dropdown-menu slot="dropdown">
    <el-dropdown-item command="a">黄金糕el-dropdown-item>
    <el-dropdown-item command="b">狮子头el-dropdown-item>
    <el-dropdown-item command="c">螺蛳粉el-dropdown-item>
    <el-dropdown-item command="d" disabled>双皮奶el-dropdown-item>
    <el-dropdown-item command="e" divided>蚵仔煎el-dropdown-item>
  el-dropdown-menu>
el-dropdown>

<style>
  .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
style>

<script>
  export default {
    methods: {
      handleCommand(command) {
        this.$message('click on item ' + command);
      }
    }
  }
script>

我主要说的是这里使用数组来代替许多下拉框

<template>
<el-dropdown @command="handleCommand">
                <span class="el-dropdown-link">
                    下拉菜单<i class="el-icon-arrow-down el-icon--right">i>
                span>
                <el-dropdown-menu slot="dropdown" >
                    <el-dropdown-item v-for="(ce,index) in kuList" :key="index" :command="ce" >{{ce}}el-dropdown-item>
                el-dropdown-menu>
            el-dropdown>
template>
<script>
  export default {
       data() {
            return {
                kuList:[],
            }
        },
    methods: {
      handleCommand(command) {
        this.$message('click on item ' + command);
      }
    }
  }
script>
<style lang="less">
    .el-dropdown-link {
        cursor: pointer;
        color: #409EFF;
    }
    .el-icon-arrow-down {
        font-size: 12px;
    }
style>

你可能感兴趣的:(Elementui - 下拉框(el-dropdown-menu组件)的使用方法)