• 请不要在回答技术问题时复制粘贴 AI 生成的内容
cliberal
V2EX  ›  程序员

求教 ant design 自定义组件,有踩过坑的么

  •  1
     
  •   cliberal · May 10, 2017 · 6298 views
    This topic created in 3290 days ago, the information mentioned may be changed or developed.

    前端新手,在使用 antd 的 table 组件时,想实现当某一行被选中时它的背景色发生变化,如下

    WechatIMG25.jpeg WechatIMG1962.jpeg

    第一张是 Material UI 的,第二张是 antd,希望实现 Material UI 的那种效果。

    antd 的 table 组件是这样的

    <Table dataSource={dataSource} columns={columns} />
    

    组件封装太深,回调没法控制到每一行,也没办法单纯通过自定义样式来实现,有没有大神提供点思路🙏

    zcw159357
        1
    zcw159357  
       May 10, 2017   ❤️ 1
    table 组件有个 rowClassName 属性 可以用来自定义某一行的 class 把选中行的 class 自定义一下就好了么..
    cliberal
        2
    cliberal  
    OP
       May 10, 2017
    @zcw159357 对哦,没注意这个属性,的确是个不错的办法,我去试试,多谢了😁
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1404 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 17:04 · PVG 01:04 · LAX 10:04 · JFK 13:04
    ♥ Do have faith in what you're doing.