Vue, elementUI, dropdown component command method to add additional parameters Method

Vue, elementUI, dropdown component command method to add additional parameters Method

When we use the dropdown components, parameters may require a lot more than just a command parameter. This requires the construction of a structure.

<el-dropdown @command="handleCommand">

<el-dropdown-menu slot="dropdown">

<template v-for="item in items">

     <el-dropdown-item v-for="it in item " :command="composeValue(it,scope.row)"/>

</template>

</el-dropdown-menu>

</el-dropdown>

Methods of treatment:

methods: {

    handleCommand(command) {

      console.log(command)

    },

    composeValue(item, row) {

      return {

        'button': item,

        'row': row

      }

    }



Author: a little black hair
link: https: //www.jianshu.com/p/b86e79ca9382
Source: Jane book
Jane book copyright reserved by the authors, are reproduced in any form, please contact the author to obtain authorization and indicate the source.

Guess you like

Origin www.cnblogs.com/duanzhenzhen/p/11084078.html