javascript - vue 元素加樣式該怎麼做
大家讲道理
大家讲道理 2017-05-16 13:45:12
0
3
776

主要問題是: 之前記得能$index傳遞一個index然後就好辦了, 怎麼知道當前tr渲染是的是第幾行資料, 如何用computed

我想改變文字顏色

#我的程式碼:

#
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回覆(3)
小葫芦

寫好樣式,然後動態綁定 :class ="{green:true,red:false.....}"

过去多啦不再A梦

你用的是element-ui框架吧,在el-table里有这么一个属性row-class-name,是一个回调函数,可以给table-cell加class。詳情你可以看官網,在最下面。
舉個栗子:(透過判斷一行資料中的數值來顯示不同的背景顏色)
template

<el-table :data="roleMenuTable" border style="width: 100%" :row-class-name="tableRowClassName">

script

methods: {
    // 已选择渲染样式
    tableRowClassName (row, index) {
      if (row.operation) {
        return 'info-row'
      } else {
        return ''
      }
    }
    }

style

<style>
.el-table .info-row{
  background: #5CB85C;
}
</style>

效果:

滿天的星座

雷雷

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!