javascript - vue 元素加样式该怎么做
问题描述
主要问题是: 之前记得能$index传递一个index然后就好办了, 怎么知道当前tr渲染是的是第几行数据, 如何用computed做
我想改变文字颜色
我的代码: 

问题解答
回答1:写好样式,然后动态绑定 :class ='{green:true,red:false.....}'
回答2:你用的是element-ui框架吧,在el-table里有这么一个属性row-class-name,是一个回调函数,可以给table-cell加class。详情你可以看一下官网,在最下面。举个栗子:(通过判断一行数据中的值来显示不同的背景颜色)template
<el-table :data='roleMenuTable' border :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>
效果:
现在也可以啊,把v-for改成v-for='(item, index) in lists',inde就是索引了
相关文章:
1. angular.js - 如何控制ngrepeat输出的个数2. html - vue项目中用到了elementUI问题3. ionic 项目 ionic build android -release 打包时报错4. javascript - 在使用 vue.js element ui的时候 怎么样保留table翻页后check的值?5. mac里的docker如何命令行开启呢?6. mysql_replication - mysql读写分离时如果单台写库也无法满足性能怎么解决7. python3.x - python3.5.2安装时make报错求助8. javascript - vue组件通过eventBus通信时,报错a.$on is not a function9. python - 如何用pandas处理分钟数据变成小时线?10. javascript - 求一款靠谱点的移动端图片查看器插件,老司机速进!

网公网安备