Skip to content

Commit 643f21f

Browse files
ffff
authored andcommitted
docs: 优化Slider文档
1 parent 9ad7cb9 commit 643f21f

File tree

1 file changed

+66
-24
lines changed

1 file changed

+66
-24
lines changed

packages/core/src/Slider/README.md

Lines changed: 66 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,68 +6,110 @@ Slider 滑块输入条
66
> 自带 Slider 已经过时,交于社区维护 [`react-native-slider`](https://github.com/react-native-community/react-native-slider),当前组件是重新封装保持 iOS/android 效果一致。
77
<!--rehype:style=border-left: 8px solid #ffe564;background-color: #ffe56440;padding: 12px 16px;-->
88
9-
![](https://user-images.githubusercontent.com/57083007/146733306-cffada07-0f11-46cc-8969-1676c9070cda.gif)<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
9+
1010

1111
### 基础示例
1212

13-
```jsx
14-
import { Fragment, useState } from 'react';
13+
```jsx mdx:preview
14+
import React, { useState } from 'react';
1515
import { Text } from 'react-native';
1616
import { Slider } from '@uiw/react-native';
1717

1818
function Demo() {
1919
const [value, setValue] = useState(0.3);
2020
return (
21-
<Fragment>
21+
<>
2222
<Slider
2323
value={value}
2424
onChange={(cValue) => setValue(cValue)}
2525
/>
2626
<Text>值:{value.toFixed(1)}</Text>
27-
</Fragment>
27+
</>
2828
);
2929
}
30+
31+
export default Demo
32+
3033
```
3134

3235
### 不显示滑块
3336

34-
```jsx
35-
import { Fragment,useState } from 'react';
37+
```jsx mdx:preview
38+
import React, { useState } from 'react';
3639
import { Slider } from '@uiw/react-native';
3740

3841
function Demo() {
3942
const [value, setValue] = useState(0.3);
4043
return (
41-
<Fragment>
42-
<Slider
43-
shownThumb={false}
44-
value={value}
45-
onChange={(cValue) => setValue(cValue)}
46-
/>
47-
</Fragment>
44+
<Slider
45+
shownThumb={false}
46+
value={value}
47+
onChange={(cValue) => setValue(cValue)}
48+
/>
4849
);
4950
}
51+
52+
export default Demo
53+
54+
5055
```
5156

5257
### 设置步长
5358

54-
```jsx
55-
import { Fragment, useState } from 'react';
59+
```jsx mdx:preview
60+
import React, { useState } from 'react';
5661
import { Slider } from '@uiw/react-native';
5762

5863
function Demo() {
5964
const [value, setValue] = useState(0.3);
6065
return (
61-
<Fragment>
62-
<Slider
63-
step={0.2}
64-
shownThumb={false}
65-
value={value}
66-
onChange={(cValue) => setValue(cValue)}
67-
/>
68-
</Fragment>
66+
<Slider
67+
step={0.2}
68+
value={value}
69+
onChange={(cValue) => setValue(cValue)}
70+
/>
71+
);
72+
}
73+
74+
export default Demo
75+
```
76+
### 自定义颜色
77+
78+
```jsx mdx:preview
79+
import React, { useState } from 'react';
80+
import { Slider } from '@uiw/react-native';
81+
82+
function Demo() {
83+
const [value, setValue] = useState(0.3);
84+
return (
85+
<Slider
86+
value={value}
87+
onChange={(cValue) => setValue(cValue)}
88+
thumbTintColor="pink"
89+
maximumTrackTintColor="pink"
90+
minimumTrackTintColor="purple"
91+
/>
6992
);
7093
}
94+
95+
export default Demo
96+
```
97+
### 禁用
98+
99+
```jsx mdx:preview
100+
import React from 'react';
101+
import { Slider } from '@uiw/react-native';
102+
103+
function Demo() {
104+
return (
105+
<Slider
106+
disabled
107+
value={0.5}
108+
/>
109+
);
110+
}
111+
112+
export default Demo
71113
```
72114

73115
### Props

0 commit comments

Comments
 (0)