antdesign vue 组件 表格带斑马纹实现

最终效果:
image.png

代码:

  updated(){
    // 表格斑马行显示
    this.renderStripe()
  },
  methods: {
        // 表格斑马行显示
      renderStripe(){
          const table=document.getElementsByClassName('ant-table-row')
          if(table.length>0){
              const rowList=[...table]
              rowList.map((row,index)=>{
                  if(index%2 !== 0) {
                      row.style.backgroundColor = '#f9f9f9'
                  } else {
                      row.style.backgroundColor = '#ffffff'
                  }
              })
          }
      },
  }

你可能感兴趣的:(antdesign vue 组件 表格带斑马纹实现)