El-table render-header custom header, nesting el-dropdown in the header, the click event of the drop-down menu cannot be triggered

  1. use the el-table render-header custom header to nest el-dropdown in the header. The click event of the drop-down menu cannot trigger

command is an event of el-dropdown. The callback of the event triggered by clicking on the menu item
code is as follows. Using the JSX syntax, the menu has been rendered, but the click does not respond. Is it possible that the event cannot be written in this way

?
  <el-table :data="tableData"  style="width: 100%">
                  <el-table-column  prop="date"  label=""  sortable  width="180">
                  </el-table-column>
                  <el-table-column  prop="name"  label=""  sortable  width="180">
                  </el-table-column>
                  <el-table-column  prop="address"  label="" sortable @sort-method="byPost">
                  </el-table-column>
                  <el-table-column :render-header="renderEmotionValue" prop="address">
                    <template slot-scope="scope">
                      <span>{{scope.row.address}}</span>
                    </template>
                  </el-table-column>
              </el-table>

method section:

 renderEmotionValue(creatElement, { column, $index }) {
      return (
        <el-dropdown command={this.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"></el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      )
    },
    handleCommand(command) {
      console.log(command)
      this.$message("click on item " + command)
    }
Apr.08,2022

Hello, landlord ~ I haven't found a good solution for the time being, but it can solve the problem. The specific code is as follows:

renderEmotionValue(creatElement, { column, $index }) {
  return (
    <el-dropdown>
    <span class='el-dropdown-link'>
    <i class='el-icon-arrow-down el-icon--right'></i>
    </span>
    <el-dropdown-menu slot='dropdown'>
    // 
    <el-dropdown-item nativeOn-click={(e) => this.handleCommand('a')}></el-dropdown-item>
    <el-dropdown-item nativeOn-click={(e) => this.handleCommand('b')}></el-dropdown-item>
    <el-dropdown-item nativeOn-click={(e) => this.handleCommand('c')}></el-dropdown-item>
    <el-dropdown-item nativeOn-click={(e) => this.handleCommand('d')}></el-dropdown-item>
    </el-dropdown-menu>
    </el-dropdown>
    )
},

command can be changed to onCommand .

<el-dropdown onCommand={ this.handleCommand }>

try this

   renderEmotionValue(creatElement, { column, $index }) {
      return (
        <el-dropdown command={this.handleCommand.bind(this) }>
          <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'></el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      )
    },
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c2a5c3-33168.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c2a5c3-33168.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?