鍍金池/ 問答/HTML/ vue+elementUI數(shù)據(jù)更新樣式混亂

vue+elementUI數(shù)據(jù)更新樣式混亂

用row-class-name給el-table設置行樣式,數(shù)據(jù)更新后行樣式渲染混亂,是不是需要用Vue.nextTick()在回調(diào)中更新,如果是,動態(tài)樣式:row-class-name="tableRowClassName"如何在回調(diào)中更新?

<el-table :data="tableList" :row-class-name="tableRowClassName">...</el-table>

<script>
    tableRowClassName({row, rowIndex}) {
        if (row.type === 2) {
            return 'success-row';
        }
        return '';
    },
    getList(){
        axios.post('/getList', {
            uid: this.uid
        })
        .then(function (response) {
            console.log(response);
            this.tableList = response.data.dataList
        })
        .catch(function (error) {
            console.log(error);
        });
    }
</script>
回答
編輯回答
夢囈

直接 :row-class-name="row.type === 2 ? 'success-row' : ''" 試試

2018年6月4日 01:57