el-dropdown用法

董霖
2023-12-01
<el-dropdown @command="handleCommand">
                    <!--  绑定指令,在methods里定义-->
                    <h1 class="el-dropdown-link exit">
                        {{username}}
                        <i class="el-icon-caret-bottom el-icon--right"></i>
                    </h1>

                    <el-dropdown-menu slot="dropdown">
                        <!-- icon是修改图标 ,command是点击后传给方法的值-->
                        <el-dropdown-item command="changepass">修改密码</el-dropdown-item>
                        <el-dropdown-item command="exit">退出</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
 handleCommand(command) {
                if (command == "exit") {
                    this.exit();
                } else {
                    this.changepass()
                }

            }
 类似资料: