ant-design-vue專案中給table表單元件的具體值等於a的那行新增預設樣式
阿新 • • 發佈:2020-08-12
需求是在狀態列列的值等於1的情況本行要顯示灰色背景色藍色顏色
template: <a-table :rowClassName = "fnRowClass"/> methods:{ fnRowClass(record,index){ console.log(record.state,index) return record.state == 0 ? "csbsTypes" :"" } } style: /deep/.csbsTypes td{ background-color: #00b4ed!important; color:red; }
說明:
1:用:rowClassName (官網api)先繫結一個函式
2:函式內第一個引數是本行具體值,從具體值判斷具體列的值等於條件,然後進行匹配返回匹配成功的class名
3:在css 加入class,注意這時候dom已經有class,用即便用最高許可權!important也不起作用:要用/deep/+類名{}
注意:ant-design-vue 修改元件樣式 有時(動態深層的)即便是能加上類名,內部寫的類的樣式也不起作用哪怕用最高許可權!important,這個時候就要在類名前新增/deep/即可
/deep/ .ant-input {
border-radius: 50px;
}