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. 关于docker下的nginx压力测试2. docker - 如何修改运行中容器的配置3. 用命令无法登陆mysql页面求解答4. dockerfile - [docker build image失败- npm install]5. angular.js - angular内容过长展开收起效果6. docker-machine添加一个已有的docker主机问题7. docker-compose中volumes的问题8. docker网络端口映射,没有方便点的操作方法么?9. docker安装后出现Cannot connect to the Docker daemon.10. docker-compose 为何找不到配置文件?

网公网安备