Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

element ui

<el-table :data="tableData" @row-click="editClick" style="width: 100%;">
    <el-table-column align="center" class-name="el-table-title" prop="title" label="标题"></el-table-column>
</el-table>

使用element Ui 的table组件的时候,我想给上面的className:el-table-title做个限制,
就是用后台返回过来的一个字段isFlay为true才让他有这个class
我改成这个:class-name="{'el-table-title': true}"虽然是可以了
但他报[Vue warn]: Invalid prop: type check failed for prop "className". Expected String,got Object. (found in component <el-table-column>)
如果我改成这个的话:class-name="{'el-table-title': isFlay === true}"
他报isFlay不存在
[Vue warn]: Property or method "isFlay" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.(found in component <demand>)
这个要怎么破!!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

:class-name="{el-table-title: isFlay === true}"
改成
:class-name="{'el-table-title': isFlay === true}"
有特殊符号的 key 值需要加单引号


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...