number.md 850 Bytes
Newer Older
niko's avatar
niko committed
1 2
---
order: 0
3 4 5
title: 
  zh-CN: 按照字符数省略
  en-US: Truncate according to the number of character
niko's avatar
niko committed
6 7
---

8 9
## zh-CN

niko's avatar
niko committed
10 11
通过设置 `length` 属性指定文本最长长度,如果超过这个长度会自动截取。

12 13 14 15
## en-US

`length` attribute specifies the maximum length where the text will automatically be truncated when exceeded.

niko's avatar
niko committed
16 17 18 19 20 21 22 23 24 25 26 27 28
````jsx
import Ellipsis from 'ant-design-pro/lib/Ellipsis';

const article = 'There were injuries alleged in three cases in 2015, and a fourth incident in September, according to the safety recall report. After meeting with US regulators in October, the firm decided to issue a voluntary recall.';

ReactDOM.render(
  <div>
    <Ellipsis length={100}>{article}</Ellipsis>
    <h4 style={{ marginTop: 24 }}>Show Tooltip</h4>
    <Ellipsis length={100} tooltip>{article}</Ellipsis>
  </div>
, mountNode);
````