需要做一个可编辑的表格,使用elementui
组件库中的table
控件,但是在表格行中使用下拉无效(可使用elementui
中的select
组件,应该是组件冲突了),又遇到过的吗?
下拉组件:https://vue-treeselect.js.org/
elementui版本:2.7.2
vue版本:2.5.10
<template>
<el-table
:data="tableData"
style="width: 100%">
<el-table-column
label="日期"
width="180">
<template slot-scope="scope">
<i class="el-icon-time"></i>
<span style="margin-left: 10px">{{ scope.row.date }}</span>
</template>
</el-table-column>
<el-table-column
label="姓名"
width="180">
<template slot-scope="scope">
<el-popover trigger="hover" placement="top">
<p>姓名: {{ scope.row.name }}</p>
<p>住址: {{ scope.row.address }}</p>
<div slot="reference" class="name-wrapper">
<el-tag size="medium">{{ scope.row.name }}</el-tag>
</div>
</el-popover>
</template>
</el-table-column>
<el-table-column
label="姓名"
width="180">
<template slot-scope="scope">
<treeselect :normalizer="normalizer" key='treekey123'
:clearable="false" :default-expand-level="3" :options="treeData"
:multiple="false" placeholder='' :show-count="false" :disable-branch-nodes="false"
:alwaysOpen='true'>
</treeselect>
</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
name: "login",
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}],
options: [{
value: '选项1',
label: '黄金糕'
}, {
value: '选项2',
label: '双皮奶'
}, {
value: '选项3',
label: '蚵仔煎'
}, {
value: '选项4',
label: '龙须面'
}, {
value: '选项5',
label: '北京烤鸭'
}],
normalizer(node) {
return {
label: node.label,
id: node.Id,
children: node.children
}
},
treeData: [
{
"Id": "11111111111111111",
"ParentId": null,
"label": "1113",
"status": 3,
"children": [
{
"Id": "22222222222222",
"ParentId": "11111111111111111",
"label": "1",
"status": 3
}
]
},
{
"Id": "3333333333333",
"ParentId": null,
"label": "22",
"status": 2,
"children": [
{
"Id": "4444444444",
"ParentId": "3333333333333",
"label": "1",
"status": 3
}
]
}
]
};
},
methods: {
}
};
</script>
找到答案了,今天翻看官方文档,发现了一个眼熟的属性:
append-to-body
(是不是和element ui
的dialog
弹框属性很像??),设置为true就好,完美解决。