element dropdown

问题:二级下拉菜单实现及点击二级下拉菜单项,一级菜单同时消失

代码如下:

<div v-for="(nav,index) in navigatorData" :key="index" class="block">
    <el-dropdown trigger="click" @command="handleCommand" placement="bottom-start" :hide-on-click="false" :ref="'operationDropdownMenuRef' + index">
        <span @click="navigatorChange(index)">{{ nav }}</span>
        <el-dropdown-menu slot="dropdown" class="menu-item">
            <template v-for="(item, itemIndex) in options">
                <el-dropdown-item v-if="!item.children" :key="itemIndex" @click.native="restoreDefault(index)" :command="item.command" :divided="nav === '文件(F)' && itemIndex === 1 || itemIndex === 4 || itemIndex === 7">
                    <div class="item-container">
                        <span>{{ item.label }}</span>
                        <span>{{ item.shortcut }}</span>
                    </div>
                </el-dropdown-item>
                <el-dropdown-item v-else :key="itemIndex" :command="item.command" :divided="itemIndex === 6">
                    <el-dropdown placement="right-start" trigger="hover" @command="handleCommand">
                        <div class="item-container">
                            <span>{{ item.label }}</span>
                            <i class="el-icon-caret-right"></i>
                        </div>
                        <el-dropdown-menu slot="dropdown" class="update-elui-style" :append-to-body="false">
                            <template v-for="(child, childIndex) in item.children">
                                <el-dropdown-item :key="childIndex" :command="child.command" @click.native="restoreDefault(index)">
                                    <span>{{ child.label }}</span>
                                </el-dropdown-item>
                            </template>
                        </el-dropdown-menu>
                    </el-dropdown>
                </el-dropdown-item>
            </template>
        </el-dropdown-menu>
    </el-dropdown>
</div>
// 关闭下拉菜单
restoreDefault(index) {
    this.$refs[`operationDropdownMenuRef${index}`][0].hide()
},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值