doc.md 1.3 KB
Newer Older
宋宋 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
# Price 组件

### 介绍

基于 xxxxxxx

### 安装

## 代码演示

### 基本用法

```tsx
14
<Price price={0} needSymbol={false} thousands={true} />
宋宋 已提交
15 16 17 18 19
```

### 有人民币符号,无千位分隔

```tsx
20
<Price price={10010.01} needSymbol={true} thousands={false} />
宋宋 已提交
21 22 23 24 25
```

### 带人民币符号,有千位分隔,保留小数点后三位

```tsx
26
<Price price={15213.1221} decimalDigits={3} needSymbol={true} thousands={true} />
宋宋 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
```

### 异步随机变更

```tsx
const [price, setPrice] = useState(Math.random() * 10000000)
useEffect(() => {
const timer = setInterval(() => {
    setPrice(Math.random() * 10000000)
}, 1000)
return () => {
    clearInterval(timer)
}
}, [])

<Price price={price} decimal-digits={3} need-symbol={true} thousands={true} />
```

## API

### Props

| 参数           | 说明                     | 类型    | 默认值 |
| -------------- | ------------------------ | ------- | ------ |
| price          | 价格数量                 | Number  | 0      |
| need-symbol    | 是否需要加上 symbol 符号 | Boolean | true   |
| symbol         | 符号类型                 | String  | &yen;  |
| decimal-digits | 小数位位数               | Number  | 2      |
| thousands      | 是否按照千分号形式显示   | Boolean | false  |