antd 的table td 超出部分隱藏並顯示省略號

//需求是描述內容過長時將超出部分隱藏並顯示省略號,鼠標放上去可查看全部信息
columns = [
     { title: '描述', dataIndex: 'desc',key:"desc",
      onCell: () => {
        return {
          style: {
            maxWidth: 150,
            overflow: 'hidden',
            whiteSpace: 'nowrap',
            textOverflow:'ellipsis',
            cursor:'pointer'
          }
        }
      },
      render: (text) => <Tooltip placement="topLeft" title={text}>{text}</Tooltip>
    },       
]

  render() {
    return(
      <Table
        dataSource = {list}
        columns = {this.columns}
        loading = {loading}
      />
    )
  }

發佈了40 篇原創文章 · 獲贊 15 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章