我正在尝试创建一个使用Tabulator的Vue组件。我是按照制表器站点的文档,并在UI中显示表格,但看起来所有的列都堆叠/坐在彼此的顶部...
目前为止的尝试:
<script>
import { TabulatorFull as Tabulator } from 'tabulator-tables'; //import Tabulator library
export default {
data() {
return {
tabulator: null, //variable to hold your table
testData: [
{ id: 1, name: "Oli Bob", progress: 12, gender: "male", rating: 1, col: "red", dob: "19/02/1984", car: 1 },
{ id: 2, name: "Mary May", progress: 1, gender: "female", rating: 2, col: "blue", dob: "14/05/1982", car: true },
{ id: 3, name: "Christine Lobowski", progress: 42, gender: "female", rating: 0, col: "green", dob: "22/05/1982", car: "true" },
{ id: 4, name: "Brendon Philips", progress: 100, gender: "male", rating: 1, col: "orange", dob: "01/08/1980" },
{ id: 5, name: "Margret Marmajuke", progress: 16, gender: "female", rating: 5, col: "yellow", dob: "31/01/1999" },
{ id: 6, name: "Frank Harbours", progress: 38, gender: "male", rating: 4, col: "red", dob: "12/05/1966", car: 1 }
]
}
},
mounted() {
//instantiate Tabulator when element is mounted
this.tabulator = new Tabulator(this.$refs.table, {
data: this.testData, //link data to table
columns: [ //define the table columns
{ title: "Name", field: "name", editor: "input", width: 100, headerVertical: true },
{ title: "Task Progress", field: "progress", hozAlign: "left", width: 100, formatter: "progress", editor: true },
{ title: "Gender", field: "gender", width: 95, editor: "select", width: 100, editorParams: { values: ["male", "female"] } },
{ title: "Rating", field: "rating", formatter: "star", hozAlign: "center", width: 100, editor: true },
{ title: "Color", field: "col", width: 130, editor: "input" },
{ title: "Date Of Birth", field: "dob", width: 130, sorter: "date", hozAlign: "center" },
{ title: "Driver", field: "car", width: 90, hozAlign: "center", formatter: "tickCross", sorter: "boolean", editor: true },
]
});
}
}
</script>
<template>
<div ref="table"></div>
</template>
我试过的事...
- 自动调整列
- 静态列宽
我肯定我错过了一些简单的东西,但我真的不知道它可能是什么。CSS问题?理想情况下,表看起来像这样:
。
1条答案
按热度按时间jtoj6r0c1#
你缺少了表格式CSS。
关于你需要做什么的文档是相当稀疏的(参见这里和这里)。
但是我认为你可以总是导入生成的CSS,比如:
有几个可用的主题,如bootstrap,material等,请参阅this list以获取选项