表Vuejs中的菜单
因此,我正在使用Element Plus Table,我想组合元素加上表和元素以及菜单IE
我希望在桌子标题中使用这种下拉菜单。
<el-menu
:default-active="activeIndex"
class="el-menu-demo"
mode="horizontal"
@select="handleSelect"
>
<el-sub-menu index="1">
<template #title>Workspace</template>
<el-menu-item index="2-1">item one</el-menu-item>
<el-menu-item index="2-2">item two</el-menu-item>
<el-menu-item index="2-3">item three</el-menu-item>
<el-sub-menu index="2-4">
<template #title>item four</template>
<el-menu-item index="2-4-1">item one</el-menu-item>
<el-menu-item index="2-4-2">item two</el-menu-item>
<el-menu-item index="2-4-3">item three</el-menu-item>
</el-sub-menu>
</el-sub-menu>
</el-menu>
我的表是
<el-table :data="filtered" border style="width: 100%" height="500" @selection-change="handleSelectionChange" @header-click="contextmenu">
<el-table-column type="selection" width="55"/>
<el-table-column fixed align="center" v-for="col in columns" :prop="col.field" :label="col.field" :key="col.field"/>
但是我在结合这两个标签时面临困难。 我发现元素加上表有一个事件@header-click =“”
存储标题值等。
我是Vue的新手,因此对任何建议都表示赞赏。
答案 @ivogelov是正确的。这是我的最终代码,我已经进行了几个更改,因为现在不推荐使用插槽。
<el-table :data="filtered" border style="width: 100%" height="500" @selection-change="handleSelectionChange" @header-click="contextmenu" >
<el-table-column type="selection" width="55"/>
<el-table-column fixed align="center" v-for="col in columns" :prop="col.field" :label="col.field" :key="col.field">
<template #header >
<el-menu
:default-active="activeIndex"
class="el-menu-demo"
mode="horizontal"
@select="handleSelect">
<el-sub-menu index="1">
<template #title>{{col.field}}</template>
<el-menu-item index="2-1">Source</el-menu-item>
<el-menu-item index="2-2">Target</el-menu-item>
</el-sub-menu>
</el-menu>
</template>
</el-table-column>
<el-table>
So, I am working with element plus table, and I want to combine the element plus table and element plus menu i.e.
I want this kind of drop down menu in my table headers.
<el-menu
:default-active="activeIndex"
class="el-menu-demo"
mode="horizontal"
@select="handleSelect"
>
<el-sub-menu index="1">
<template #title>Workspace</template>
<el-menu-item index="2-1">item one</el-menu-item>
<el-menu-item index="2-2">item two</el-menu-item>
<el-menu-item index="2-3">item three</el-menu-item>
<el-sub-menu index="2-4">
<template #title>item four</template>
<el-menu-item index="2-4-1">item one</el-menu-item>
<el-menu-item index="2-4-2">item two</el-menu-item>
<el-menu-item index="2-4-3">item three</el-menu-item>
</el-sub-menu>
</el-sub-menu>
</el-menu>
My table is
<el-table :data="filtered" border style="width: 100%" height="500" @selection-change="handleSelectionChange" @header-click="contextmenu">
<el-table-column type="selection" width="55"/>
<el-table-column fixed align="center" v-for="col in columns" :prop="col.field" :label="col.field" :key="col.field"/>
But I am facing a hard time in combining these two tags.
I found out that element plus table has an event @header-click=""
that stores the header values etc, but I don't know how I can use that to call the menu tag of element plus.
I am new to vue so any suggestions are appreciated.
ANSWER
@IVOGELOV is correct. Here is my final code, I have made a couple of changes since slot-scope is now deprecated.
<el-table :data="filtered" border style="width: 100%" height="500" @selection-change="handleSelectionChange" @header-click="contextmenu" >
<el-table-column type="selection" width="55"/>
<el-table-column fixed align="center" v-for="col in columns" :prop="col.field" :label="col.field" :key="col.field">
<template #header >
<el-menu
:default-active="activeIndex"
class="el-menu-demo"
mode="horizontal"
@select="handleSelect">
<el-sub-menu index="1">
<template #title>{{col.field}}</template>
<el-menu-item index="2-1">Source</el-menu-item>
<el-menu-item index="2-2">Target</el-menu-item>
</el-sub-menu>
</el-menu>
</template>
</el-table-column>
<el-table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在列中使用
标题
插槽或render-header
函数,如此中文文章“ nofollow noreferrer”>这个github问题。You can use the
header
slot in columns or therender-header
function as explained in this Chinese article or this Github issue.