【问题标题】:Why bootstrap table example not working for me?为什么引导表示例对我不起作用?
【发布时间】:2019-09-16 16:18:32
【问题描述】:

我有一个像this bootstrap table 这样的表的项目。

Codesandbox

模板:

<b-table small :fields="fields" :items="items">
      <template v-slot:cell(index)="data">
        {{ data.index + 1 }}
      </template>

      <!-- A custom formatted column -->
      <template v-slot:cell(name)="data">
        <b class="text-info">{{ data.value.last.toUpperCase() }}</b>, <b>{{ data.value.first }}</b>
      </template>

      <!-- A virtual composite column -->
      <template v-slot:cell(nameage)="data">
        {{ data.item.name.first }} is {{ data.item.age }} years old
      </template>

      <!-- Optional default data cell scoped slot -->
      <template v-slot:cell()="data">
        <i>{{ data.value }}</i>
      </template>
    </b-table>

还有脚本:

fields: [
          // A virtual column that doesn't exist in items
          'index',
          // A column that needs custom formatting
          { key: 'name', label: 'Full Name' },
          // A regular column
          'age',
          // A regular column
          'sex',
          // A virtual column made up from two fields
          { key: 'nameage', label: 'First name and age' }
        ],
        items: [
          { name: { first: 'John', last: 'Doe' }, sex: 'Male', age: 42 },
          { name: { first: 'Jane', last: 'Doe' }, sex: 'Female', age: 36 },
          { name: { first: 'Rubin', last: 'Kincade' }, sex: 'Male', age: 73 },
          { name: { first: 'Shirley', last: 'Partridge' }, sex: 'Female', age: 62 }
        ]

引导表有效。我正在复制此代码并且示例不起作用。我不明白为什么。

问题:那么,为什么引导表示例不起作用?

【问题讨论】:

  • 请提供更多详细信息,如 vue 版本和控制台错误
  • 您的沙箱为我生成了一个具有依赖关系的工作示例:bootstrap:4.3.1bootstrap-vue:2.0.1vue:2.6.10。对于低于2.0.0bootstrap-vue 的版本,我会遇到一些奇怪的行为。
  • 谢谢!我更新了依赖项并且一切正常!

标签: vue.js bootstrap-vue


【解决方案1】:

你好,我也有同样的问题。 我有一些自定义字段表,在 vue devtools 上已经看到了数据。在 vuex 绑定中。 但是在自定义表上没有数据可以出现,只有可用的数据量。 这是我的模板代码

<template>
  <div class="table-responsive">
    <b-table striped hover :items="todos.data" :fields="fields" show-empty>
      <template slot="jadwal" slot-scope="row">
        <td class="parent-row">{{ row.item.name }}</td>
      </template>
    </b-table>
  </div>
</template>

和这个对象的vuex绑定

{"current_page":1,"data":[{"id":1,"name":"Belajar Vue Laravel","note":"Apa aja boleh deh ini deskripsinnya","due_date":"2019-09-30","status":0,"created_at":"2019-09-29 18:23:51","updated_at":"2019-09-29 18:23:51"},{"id":2,"name":"Belajar mengerti kamu","note":"you are my everythings","due_date":"2019-10-01","status":1,"created_at":"2019-09-29 18:23:51","updated_at":"2019-09-29 18:23:51"}],"first_page_url":"http://localhost:8000/api/todo?page=1","from":1,"last_page":1,"last_page_url":"http://localhost:8000/api/todo?page=1","next_page_url":null,"path":"http://localhost:8000/api/todo","per_page":10,"prev_page_url":null,"to":2,"total":2}

【讨论】:

  • Boostrap-VueVue 使用的是什么版本?
  • 这里“依赖”:{“bootstrap”:“^4.3.1”,“bootstrap-vue”:“^2.0.2”,“vue”:“^2.6.10”,“ vue-router": "^3.1.3", "vuex": "^3.1.1" }
  • 在这种情况下,您需要使用与问题中相同的插槽格式。 &lt;template v-slot:cell(jadwal)="row"&gt;&lt;/template&gt;bootstrap-vue.js.org/docs/components/table/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-20
  • 1970-01-01
  • 2012-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多