(Vue 组件)Tabulator 列在 UI 中彼此堆叠 - 如何解决?

问题描述 投票:0回答:1

我正在尝试创建一个使用 Tabulator 的 Vue 组件。我正在关注 Tabulator 网站上的文档,并在 UI 中显示了表格,但看起来所有的列都堆叠/坐在彼此之上......

stacked columns

我的代码是...

<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 问题? 理想情况下,桌子看起来像这样......

enter image description here

javascript vue.js tabulator
1个回答
0
投票

您缺少表格 CSS,添加一个导入语句:

@import  "~/tabulator-tables/dist/css/tabulator.min.css";

有关更多信息,请参阅文档

© www.soinside.com 2019 - 2024. All rights reserved.