项目开发过程中,需要实现操作栏位图标按钮与文字按钮切换效果,在实现文字按钮过程中,大致思路如下:操作栏位只展示前2个菜单,之后的菜单采用更多方式展示,通过点击更多展示其余菜单按钮。
实现代码如下:
<template slot-scope="scope">
<el-dropdown :split-button="false" trigger="click" type="text" @command="handleCommand" class="dropdown el-dropdown-link">
<span>
更多
<i class="el-icon-caret-bottom el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown" v-if="!!user.hobbies && user.hobbies.length > 0">
<template v-for="item in user.hobbies">
<el-dropdown-item @click.native="toMethod(item.methodnm, scope.row)">{{ item.name }}</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
export default {
methods: {
toMethod (methodnm, inputParam) {
switch (methodnm) {
case 'a':
aMethod(inputParam)
break
case 'b':
aMethod(inputParam)
break
...
}
}
}
}
</script>
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END