【问题标题】:vue-tables-2 color cell backgroundvue-tables-2 彩色单元格背景
【发布时间】:2018-09-21 04:03:21
【问题描述】:

我正在尝试研究如何根据单元格中的文本(例如“绿色”)呈现具有特定背景颜色的单元格。

使用模板 (https://github.com/matfish2/vue-tables-2#templates) 似乎可以做到这一点,但我不了解如何在单页 vue 应用程序中使用 props.index 将特定单元格呈现为特定颜色。

<v-client-table :data="entries" :columns="['id', 'name' ,'age', 'edit']">
      <a slot="edit" slot-scope="props" class="fa fa-edit" :href="edit(props.row.id)"></a>
</v-client-table>
#Note: You can get the index of the current row relative to the entire data set using props.index

有什么想法吗?

【问题讨论】:

  • 它只是一个单元格,而不是您想要正确着色的整行?
  • 是的,没错(我登录已经有一段时间了)

标签: vue.js vuejs2 vue-tables-2


【解决方案1】:

对于那些需要将某个类应用于整行的人:

options: {
  rowClassCallback: function(row) { return 'bg-warning'}, //Using Boostrap4
}

编辑: 我认为documentation 已更新。

cellClasses:{
  balance: [
    {
        class:'low-balance',
        condition: row => row.balance < 100
    }
  ]
}

【讨论】:

  • 知道如何为单个单元格执行此操作吗?
  • @proximacentauri 你可以使用插槽&lt;div slot="columnName" slot-scope="props" :class="{'your-class': functionToCheckValue(props.row)}"&gt;{{props.row.columnName}}&lt;/div&gt;vue-tables-2 slots
猜你喜欢
  • 1970-01-01
  • 2022-12-12
  • 2015-11-29
  • 1970-01-01
  • 1970-01-01
  • 2014-10-08
  • 2014-05-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多