行的 style 的回调方法,也可以使用一个固定的 Object 为所有行设置一样的 Style。
Function({row, rowIndex})/Object
- <!DOCTYPE html>
- <html>
-
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>AdminLTE 2 | Morris.js Charts</title>
- <!-- Tell the browser to be responsive to screen width -->
- <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
- <link rel="stylesheet" href="../plugins/elementUI/elementUI.css">
- <style>
- .green{color:green;}
- </style>
- </head>
-
- <body class="">
-
- <div id="demo">
- <el-table :data="tableData" style="width: 100%" :row-style="rowStyle">
- <el-table-column prop="date" label="Date" width="180">
- </el-table-column>
- <el-table-column prop="name" label="Name" width="180">
- </el-table-column>
- <el-table-column prop="address" label="Address">
- </el-table-column>
- </el-table>
- </div>
- <script src="../js/vue.js"></script>
- <script src="../plugins/elementUI/elementUI.js"></script>
- <script>
- var demo = new Vue({
- el: '#demo',
- data: {
- tableData: [{
- date: '2016-05-03',
- name: 'Tom',
- address: 'No. 189, Grove St, Los Angeles'
- }, {
- date: '2016-05-02',
- name: 'Tom',
- address: 'No. 189, Grove St, Los Angeles'
- }, {
- date: '2016-05-03',
- name: 'Tom',
- address: 'No. 189, Grove St, Los Angeles'
- }, {
- date: '2016-05-01',
- name: 'Tom',
- address: 'No. 189, Grove St, Los Angeles'
- }]
- },
- methods: {
- rowStyle({ row, rowIndex}) {
- if (rowIndex === 0) {
- return 'color:green'
- } else {
- return ''
- }
- }
- }
- })
- </script>
- </body>
-
- </html>