Vue+Element UI表格列的显示和隐藏
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
如下代码:
<template>
<div>
<el-table
:data="tabledate"
height="400"
>
//使用v-if else 控制两列的显示和隐藏,每个列必须加唯一标识符:key="Math.random()",否则会不起作用,无法控制显示与隐藏
<el-table-column type="selection" width="50" v-if="showColumn==true" :key="Math.random()"></el-table-column>
<el-table-column label="序号" prop="id" v-else :key="Math.random()"></el-table-column>
<el-table-column label="英文名" prop="value"></el-table-column>
<el-table-column label="中文名" prop="label"></el-table-column>
</el-table>
<el-button plain style="width:100px" @click="showColumn=true">显示</el-button>
<el-button plain style="width:100px" @click="showColumn=false">隐藏</el-button>
</div>
</template>
<script>
export default {
name: "TableColumnShowHideDemo",
data() {
return {
table_interval: null,
//控制列的显示和隐藏
showColumn: false,
tabledate: [
{ id: "1", value: "right", label: "正确" },
{ id: "2", value: "wrong", label: "错误" },
{ id: "3", value: "rightorwrong", label: "正确or错误" },
{ id: "4", value: "right", label: "正确" },
{ id: "5", value: "wrong", label: "错误" },
{ id: "6", value: "rightorwrong", label: "正确or错误" },
{ id: "7", value: "right", label: "正确" },
{ id: "8", value: "wrong", label: "错误" },
{ id: "9", value: "rightorwrong", label: "正确or错误" },
{ id: "10", value: "right", label: "正确" },
{ id: "11", value: "wrong", label: "错误" },
{ id: "12", value: "rightorwrong", label: "正确or错误" },
{ id: "13", value: "right", label: "正确" },
{ id: "14", value: "wrong", label: "错误" },
{ id: "15", value: "rightorwrong", label: "正确or错误" }
]
};
},
methods: {}
};
</script>
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:3 个月前 )
c345bb45
7 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献5条内容
所有评论(0)