2018-05-11 11:30:56 +08:00
|
|
|
|
/**
|
|
|
|
|
*
|
2018-08-16 21:04:12 +08:00
|
|
|
|
* @title 简单表格、文字过长,两种tip
|
|
|
|
|
* 【Tooltip】
|
2018-05-11 11:30:56 +08:00
|
|
|
|
* @description
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React, { Component } from "react";
|
|
|
|
|
import Button from "bee-button";
|
2018-08-16 21:04:12 +08:00
|
|
|
|
import Tooltip from "bee-tooltip";
|
2018-05-11 11:30:56 +08:00
|
|
|
|
import Table from "../../src";
|
|
|
|
|
|
|
|
|
|
const columns = [
|
2018-09-11 15:50:10 +08:00
|
|
|
|
{
|
|
|
|
|
title: "用户名", dataIndex: "a", key: "a", width: 80, className: "rowClassName",
|
|
|
|
|
render: (text, record, index) => {
|
|
|
|
|
return (
|
2018-08-16 21:04:12 +08:00
|
|
|
|
<Tooltip inverse overlay={text}>
|
2018-09-11 15:50:10 +08:00
|
|
|
|
<span tootip={text} style={{
|
|
|
|
|
display: "inline-block",
|
|
|
|
|
width: "100px",
|
|
|
|
|
textOverflow: "ellipsis",
|
|
|
|
|
overflow: "hidden",
|
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
|
verticalAlign: "middle",
|
|
|
|
|
}}>{text}</span>
|
2018-08-16 21:04:12 +08:00
|
|
|
|
</Tooltip>
|
2018-09-11 15:50:10 +08:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-08-16 21:04:12 +08:00
|
|
|
|
{ id: "123", title: "性别", dataIndex: "b", key: "b", width: 100 },
|
|
|
|
|
{ title: "年龄", dataIndex: "c", key: "c", width: 200 },
|
2018-05-11 11:30:56 +08:00
|
|
|
|
{
|
|
|
|
|
title: "操作",
|
|
|
|
|
dataIndex: "d",
|
|
|
|
|
key: "d",
|
|
|
|
|
render(text, record, index) {
|
|
|
|
|
return (
|
2018-09-11 15:50:10 +08:00
|
|
|
|
<div style={{ position: 'relative' }} title={text} >
|
|
|
|
|
<a
|
|
|
|
|
href="javascript:;"
|
|
|
|
|
tooltip={text}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
alert('这是第' + index + '列,内容为:' + text);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
一些操作
|
2018-05-11 11:30:56 +08:00
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const data = [
|
|
|
|
|
{ a: "令狐冲", b: "男", c: 41, d: "操作", key: "1" },
|
|
|
|
|
{ a: "杨过叔叔的女儿黄蓉", b: "男", c: 67, d: "操作", key: "2" },
|
|
|
|
|
{ a: "郭靖", b: "男", c: 25, d: "操作", key: "3" }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
class Demo1 extends Component {
|
|
|
|
|
|
2018-09-11 15:50:10 +08:00
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
data: data,
|
|
|
|
|
selectedRowIndex: 0
|
|
|
|
|
}
|
2018-05-11 11:30:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
|
|
|
|
<Table
|
|
|
|
|
columns={columns}
|
|
|
|
|
data={data}
|
2018-09-11 15:50:10 +08:00
|
|
|
|
onRowClick={(record, index, indent) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
selectedRowIndex: index
|
2018-05-11 11:30:56 +08:00
|
|
|
|
});
|
|
|
|
|
}}
|
2018-09-11 15:50:10 +08:00
|
|
|
|
/>
|
2018-05-11 11:30:56 +08:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Demo1;
|