javascript - How to add styles to vue elements
大家讲道理
大家讲道理 2017-05-16 13:45:12
0
3
779

The main problem is: I remembered that I could $indexpass an index and it would be easy to handle. How do I know which row of data is currently being rendered by tr? How to use computedDo

I want to change the text color

My code:

大家讲道理
大家讲道理

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

reply all(3)
小葫芦

Write the style and then bind it dynamically: class ="{green:true,red:false....}"

过去多啦不再A梦

You are using the element-ui framework, add class in el-table里有这么一个属性row-class-name,是一个回调函数,可以给table-cell. For details, you can check out the official website, at the bottom.
For example: (display different background colors by judging the value in a row of data)
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>

Effect:

滿天的星座
现在也可以啊,把v-for改成v-for="(item, index) in lists",inde就是索引了
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!