Element UI el-table-column 设置列背景色
您可以使用slot-scope来自定义列的背景色。\n\n首先,在el-table-column中添加一个slot-scope属性,并指定一个名称,比如scope,用于接收列的数据。\n\n然后,在template中使用scope.row来获取当前行的数据,根据需要设置背景色。\n\n例如,如果您想要根据某个条件来设置列的背景色,可以这样做:\n\nhtml\n<el-table-column label="姓名" prop="name">\n <template slot-scope="scope">\n <div :style="{ backgroundColor: scope.row.condition ? 'red' : 'white' }">\n {{ scope.row.name }}\n </div>\n </template>\n</el-table-column>\n\n\n在上面的示例中,如果scope.row.condition为true,则设置背景色为红色,否则设置为白色。\n\n您可以根据自己的需求来修改背景色的设置条件和颜色。
原文地址: https://www.cveoy.top/t/topic/qeV9 著作权归作者所有。请勿转载和采集!