el-dropdown drop-down box click event, get the value and label of the clicked option

 command event

<el-dropdown @command="handleCommand">
  <span>
    经销料种<i class="el-icon-arrow-down el-icon--right"></i>
  </span>
  <el-dropdown-menu slot="dropdown">
    <el-dropdown-item
      v-for="item in distributionVariety"
      :key="item.lineCode"
      :command="item.lineCode"
    >
      {
   
   { item.lineName }}
   </el-dropdown-item>
 </el-dropdown-menu>
</el-dropdown>

Use the find method of the array to find the lineName value of the click option 

handleCommand(command) {
      const item = this.distributionVariety.find((item) => item.lineCode === command);
      console.log(`点击了${item.lineName}`);
      if (item.lineCode) {
        this.selectedDistriVariety.push(item)
        console.log(this.selectedDistriVariety);
      }
    },

Guess you like

Origin blog.csdn.net/Dolores_zsq/article/details/130585319