@mijadesign/nut-mcp 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -0
- package/dist/services/aliases.service.d.ts +1 -0
- package/dist/services/aliases.service.js +19 -0
- package/dist/services/doc-parser.service.d.ts +3 -0
- package/dist/services/doc-parser.service.js +162 -0
- package/dist/services/index.services.d.ts +3 -0
- package/dist/services/index.services.js +71 -0
- package/dist/services/paths.service.d.ts +5 -0
- package/dist/services/paths.service.js +18 -0
- package/dist/tools/base.tool.d.ts +8 -0
- package/dist/tools/base.tool.js +27 -0
- package/dist/tools/get-component-doc.tool.d.ts +12 -0
- package/dist/tools/get-component-doc.tool.js +40 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/list-components.tool.d.ts +8 -0
- package/dist/tools/list-components.tool.js +32 -0
- package/dist/tools/search-components.tool.d.ts +12 -0
- package/dist/tools/search-components.tool.js +61 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/index.js +1 -0
- package/docs/docs/aliases.json +59 -0
- package/docs/docs/components/base/button/index.md +415 -0
- package/docs/docs/components/base/cell/index.md +279 -0
- package/docs/docs/components/base/configprovider/index.md +215 -0
- package/docs/docs/components/base/image/index.md +282 -0
- package/docs/docs/components/base/overlay/index.md +288 -0
- package/docs/docs/components/dentry/cascader/index.md +1080 -0
- package/docs/docs/components/dentry/checkbox/index.md +842 -0
- package/docs/docs/components/dentry/datepicker/index.md +489 -0
- package/docs/docs/components/dentry/form/index.md +457 -0
- package/docs/docs/components/dentry/input/index.md +257 -0
- package/docs/docs/components/dentry/picker/index.md +621 -0
- package/docs/docs/components/dentry/radio/index.md +364 -0
- package/docs/docs/components/dentry/searchbar/index.md +317 -0
- package/docs/docs/components/dentry/selector/index.md +295 -0
- package/docs/docs/components/dentry/switch/index.md +300 -0
- package/docs/docs/components/dentry/textarea/index.md +231 -0
- package/docs/docs/components/dentry/uploader/index.md +745 -0
- package/docs/docs/components/exhibition/collapse/index.md +339 -0
- package/docs/docs/components/exhibition/swiper/index.md +385 -0
- package/docs/docs/components/exhibition/tag/index.md +253 -0
- package/docs/docs/components/feedback/dialog/index.md +306 -0
- package/docs/docs/components/feedback/drag/index.md +164 -0
- package/docs/docs/components/feedback/empty/index.md +211 -0
- package/docs/docs/components/feedback/infiniteloading/index.md +397 -0
- package/docs/docs/components/feedback/noticebar/index.md +175 -0
- package/docs/docs/components/feedback/popup/index.md +563 -0
- package/docs/docs/components/feedback/pulltorefresh/index.md +254 -0
- package/docs/docs/components/feedback/toast/index.md +355 -0
- package/docs/docs/components/layout/divider/index.md +162 -0
- package/docs/docs/components/layout/grid/index.md +386 -0
- package/docs/docs/components/layout/space/index.md +196 -0
- package/docs/docs/components/nav/tabs/index.md +955 -0
- package/docs/docs/components-index.json +233 -0
- package/package.json +34 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 6
|
|
3
|
+
demoUrl: 'https://frontend.mishudata.com/mobile/demo/#/base/pages/image/index'
|
|
4
|
+
group:
|
|
5
|
+
title: 基础组件
|
|
6
|
+
order: 2
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Image 图片
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
增强版的 img 标签,提供多种图片填充模式,支持图片加载中提示、加载失败提示。
|
|
13
|
+
|
|
14
|
+
## 引入
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { Image } from '@mijadesign/mjui-react-taro';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 示例代码
|
|
21
|
+
|
|
22
|
+
### 基础用法
|
|
23
|
+
|
|
24
|
+
借助 Taro Image 标签实现,可以透传使用 Taro Image 的属性。
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { Image } from '@mijadesign/mjui-react-taro'
|
|
29
|
+
import React from 'react'
|
|
30
|
+
|
|
31
|
+
const Demo1 = () => {
|
|
32
|
+
const src = 'https://sblp-oss.mibaodata.com/static/front-end/home/homeBanner.png'
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<Image src={src} height={159} />
|
|
36
|
+
</>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
export default Demo1
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 圆形图片
|
|
44
|
+
|
|
45
|
+
通过 radius 属性可以设置图片变圆,注意当图片宽高不相等且 fit 为 contain 或 scale-down 时,将无法填充一个完整的圆形。
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { Image } from '@mijadesign/mjui-react-taro'
|
|
50
|
+
import React from 'react'
|
|
51
|
+
|
|
52
|
+
const Demo2 = () => {
|
|
53
|
+
const src = 'https://sblp-oss.mibaodata.com/static/front-end/home/homeBanner.png'
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
57
|
+
<div style={{ width: 98 }}>
|
|
58
|
+
<Image src={src} mode="aspectFit" width="80" height="80" radius="50%" />
|
|
59
|
+
</div>
|
|
60
|
+
<div style={{ width: 98 }}>
|
|
61
|
+
<Image src={src} mode="scaleToFill" width="80" height="80" radius="50%" />
|
|
62
|
+
</div>
|
|
63
|
+
<div style={{ width: 98 }}>
|
|
64
|
+
<Image src={src} mode="scaleToFill" width="80" height="80" radius="10px" />
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
export default Demo2
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 加载中提示
|
|
75
|
+
|
|
76
|
+
`Image` 组件提供了默认的加载中提示,支持通过 `loading` 自定义内容。
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { Image } from '@mijadesign/mjui-react-taro'
|
|
81
|
+
import { Loading } from '@nutui/icons-react-taro'
|
|
82
|
+
import { View } from '@tarojs/components'
|
|
83
|
+
import React from 'react'
|
|
84
|
+
|
|
85
|
+
const Demo3 = () => {
|
|
86
|
+
const imageText: React.CSSProperties = {
|
|
87
|
+
width: 80,
|
|
88
|
+
marginTop: 5,
|
|
89
|
+
textAlign: 'center',
|
|
90
|
+
color: '#999',
|
|
91
|
+
}
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
95
|
+
<div style={{ width: 98 }}>
|
|
96
|
+
<Image width="80" height="80" />
|
|
97
|
+
<View style={imageText}>默认</View>
|
|
98
|
+
</div>
|
|
99
|
+
<div style={{ width: 98 }}>
|
|
100
|
+
<Image width="80" height="80" loading={<Loading className="nut-icon-loading" />} />
|
|
101
|
+
<View style={imageText}>自定义</View>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
export default Demo3
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 加载失败
|
|
112
|
+
|
|
113
|
+
`Image` 组件提供了默认的加载失败提示,支持通过 `error` 自定义内容。
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { Image } from '@mijadesign/mjui-react-taro'
|
|
118
|
+
import { Failure } from '@nutui/icons-react-taro'
|
|
119
|
+
import { View } from '@tarojs/components'
|
|
120
|
+
import React from 'react'
|
|
121
|
+
|
|
122
|
+
const Demo4 = () => {
|
|
123
|
+
const imageText: React.CSSProperties = {
|
|
124
|
+
width: 80,
|
|
125
|
+
marginTop: 5,
|
|
126
|
+
textAlign: 'center',
|
|
127
|
+
color: '#999',
|
|
128
|
+
}
|
|
129
|
+
return (
|
|
130
|
+
<>
|
|
131
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
132
|
+
<div style={{ width: 98 }}>
|
|
133
|
+
<Image src="https://x" width="80" height="80" />
|
|
134
|
+
<View style={imageText}>默认</View>
|
|
135
|
+
</div>
|
|
136
|
+
<div style={{ width: 98 }}>
|
|
137
|
+
<Image src="https://x" width="80" height="80" error={<Failure />} />
|
|
138
|
+
<View style={imageText}>自定义</View>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
export default Demo4
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Image + text 模式
|
|
149
|
+
|
|
150
|
+
`Image` 组件和文本组合。
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import React from 'react'
|
|
155
|
+
import { Image } from '@mijadesign/mjui-react-taro'
|
|
156
|
+
|
|
157
|
+
const Demo5 = () => {
|
|
158
|
+
return (
|
|
159
|
+
<>
|
|
160
|
+
<Image
|
|
161
|
+
src="https://sblp-oss.mibaodata.com/static/front-end/home/homeBanner.png"
|
|
162
|
+
width="30"
|
|
163
|
+
height="30"
|
|
164
|
+
style={{ marginRight: '10px' }}
|
|
165
|
+
onError={() => {
|
|
166
|
+
console.log('image error')
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
169
|
+
<div
|
|
170
|
+
style={{
|
|
171
|
+
width: '220px',
|
|
172
|
+
}}
|
|
173
|
+
>
|
|
174
|
+
雪纺衫女2021年春季新款洋气轻熟上衣
|
|
175
|
+
</div>
|
|
176
|
+
</>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
export default Demo5
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 填充模式
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
import { Image } from '@mijadesign/mjui-react-taro'
|
|
188
|
+
import React from 'react'
|
|
189
|
+
|
|
190
|
+
const Demo6 = () => {
|
|
191
|
+
const src = 'https://sblp-oss.mibaodata.com/static/front-end/home/homeBanner.png'
|
|
192
|
+
const modes = ['scaleToFill', 'aspectFit', 'aspectFill', 'widthFix', 'heightFix']
|
|
193
|
+
return (
|
|
194
|
+
<>
|
|
195
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
196
|
+
{modes.map((mode) => {
|
|
197
|
+
return (
|
|
198
|
+
<div style={{ width: 100, height: 100 }} key={mode}>
|
|
199
|
+
<Image src={src} mode={mode as any} width="80" height="80" />
|
|
200
|
+
</div>
|
|
201
|
+
)
|
|
202
|
+
})}
|
|
203
|
+
</div>
|
|
204
|
+
</>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
export default Demo6
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### 图片位置
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { Image } from '@mijadesign/mjui-react-taro'
|
|
216
|
+
import React from 'react'
|
|
217
|
+
|
|
218
|
+
const Demo7 = () => {
|
|
219
|
+
const src = 'https://sblp-oss.mibaodata.com/static/front-end/home/homeBanner.png'
|
|
220
|
+
const modes = ['top', 'bottom', 'center', 'left', 'right', 'top left', 'top right', 'bottom left', 'bottom right']
|
|
221
|
+
return (
|
|
222
|
+
<>
|
|
223
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
224
|
+
{modes.map((mode) => {
|
|
225
|
+
return (
|
|
226
|
+
<div style={{ width: 100, height: 100 }} key={mode}>
|
|
227
|
+
<Image src={src} mode={mode as any} width="80" height="80" />
|
|
228
|
+
</div>
|
|
229
|
+
)
|
|
230
|
+
})}
|
|
231
|
+
</div>
|
|
232
|
+
</>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
export default Demo7
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 图片懒加载
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
```tsx
|
|
243
|
+
import { Image } from '@mijadesign/mjui-react-taro'
|
|
244
|
+
import { ScrollView } from '@tarojs/components'
|
|
245
|
+
import React from 'react'
|
|
246
|
+
|
|
247
|
+
const Demo8 = () => {
|
|
248
|
+
const src = 'https://sblp-oss.mibaodata.com/static/front-end/home/homeBanner.png'
|
|
249
|
+
return (
|
|
250
|
+
<>
|
|
251
|
+
<ScrollView style={{ height: '350px' }} scrollY>
|
|
252
|
+
{[
|
|
253
|
+
...new Array(3).fill(src),
|
|
254
|
+
'https://sblp-oss.mibaodata.com/static/front-end/home/homeBanner.png',
|
|
255
|
+
'https://sblp-oss.mibaodata.com/static/front-end/home/homeBanner.png',
|
|
256
|
+
].map((_, i) => {
|
|
257
|
+
return <Image key={i} src={_} lazyLoad width="100%" height="150" />
|
|
258
|
+
})}
|
|
259
|
+
</ScrollView>
|
|
260
|
+
</>
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
export default Demo8
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Image
|
|
268
|
+
|
|
269
|
+
### Props
|
|
270
|
+
|
|
271
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
272
|
+
| --- | --- | --- | --- |
|
|
273
|
+
| src | 图片链接 | `string` | `-` |
|
|
274
|
+
| width | 宽度,默认单位`px` | `string` | `-` |
|
|
275
|
+
| height | 高度,默认单位`px` | `string` | `-` |
|
|
276
|
+
| radius | 圆角大小 | `string` \| `number` | `-` |
|
|
277
|
+
| error | 是否展示图片加载失败 | `boolean \| ReactNode` | `true` |
|
|
278
|
+
| loading | 是否展示加载中图片 | `boolean \| ReactNode` | `false` |
|
|
279
|
+
| onLoad | 图片加载完后触发 | `() => void` | `-` |
|
|
280
|
+
| onError | 图片加载失败后触发 | `() => void` | `-` |
|
|
281
|
+
|
|
282
|
+
### 直接使用 Taro 现有 Image 组件开发 [参考文档](https://taro-docs.jd.com/docs/components/media/image)
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 7
|
|
3
|
+
demoUrl: 'https://frontend.mishudata.com/mobile/demo/#/base/pages/overlay/index'
|
|
4
|
+
group:
|
|
5
|
+
title: 基础组件
|
|
6
|
+
order: 2
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Overlay 遮罩层 <Badge>2.0.0</Badge>
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
创建一个遮罩层,通常用于阻止用户进行其他操作
|
|
13
|
+
|
|
14
|
+
## 引入
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { Overlay } from '@mijadesign/mjui-react-taro';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 示例代码
|
|
21
|
+
|
|
22
|
+
### 基础用法
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import React, { useState } from 'react'
|
|
27
|
+
import { Button, Overlay } from '@mijadesign/mjui-react-taro'
|
|
28
|
+
|
|
29
|
+
const Demo1 = () => {
|
|
30
|
+
const [visible, setVisible] = useState(false)
|
|
31
|
+
const handleToggleShow = () => {
|
|
32
|
+
setVisible(true)
|
|
33
|
+
}
|
|
34
|
+
const onClose = () => {
|
|
35
|
+
setVisible(false)
|
|
36
|
+
}
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<Button type="primary" onClick={handleToggleShow}>
|
|
40
|
+
显示遮罩层
|
|
41
|
+
</Button>
|
|
42
|
+
<Overlay
|
|
43
|
+
visible={visible}
|
|
44
|
+
onClick={onClose}
|
|
45
|
+
style={{ '--nutui-overlay-zIndex': 2020 }}
|
|
46
|
+
afterShow={() => {
|
|
47
|
+
console.log('afterShow')
|
|
48
|
+
}}
|
|
49
|
+
afterClose={() => {
|
|
50
|
+
console.log('afterClose')
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
</>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
export default Demo1
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 自定义遮罩样式
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import React, { useState } from 'react'
|
|
65
|
+
import { Button, Overlay } from '@mijadesign/mjui-react-taro'
|
|
66
|
+
|
|
67
|
+
const Demo2 = () => {
|
|
68
|
+
const [visible, setVisible] = useState(false)
|
|
69
|
+
const handleToggleShow = () => {
|
|
70
|
+
setVisible(true)
|
|
71
|
+
}
|
|
72
|
+
const onClose = () => {
|
|
73
|
+
setVisible(false)
|
|
74
|
+
}
|
|
75
|
+
return (
|
|
76
|
+
<>
|
|
77
|
+
<Button type="primary" onClick={handleToggleShow}>
|
|
78
|
+
自定义遮罩样式
|
|
79
|
+
</Button>
|
|
80
|
+
<Overlay
|
|
81
|
+
visible={visible}
|
|
82
|
+
onClick={onClose}
|
|
83
|
+
style={{
|
|
84
|
+
backgroundColor: 'rgba(0, 0, 0, .4)',
|
|
85
|
+
'--nutui-overlay-zIndex': 2000,
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
</>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
export default Demo2
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 设置动画时间
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import React, { useState } from 'react'
|
|
100
|
+
import { Button, Overlay } from '@mijadesign/mjui-react-taro'
|
|
101
|
+
|
|
102
|
+
const Demo3 = () => {
|
|
103
|
+
const [visible, setVisible] = useState(false)
|
|
104
|
+
const handleToggleShow = () => {
|
|
105
|
+
setVisible(true)
|
|
106
|
+
}
|
|
107
|
+
const onClose = () => {
|
|
108
|
+
setVisible(false)
|
|
109
|
+
}
|
|
110
|
+
return (
|
|
111
|
+
<>
|
|
112
|
+
<Button type="primary" onClick={handleToggleShow}>
|
|
113
|
+
设置动画时间
|
|
114
|
+
</Button>
|
|
115
|
+
<Overlay
|
|
116
|
+
visible={visible}
|
|
117
|
+
onClick={onClose}
|
|
118
|
+
style={{ '--nutui-overlay-animation-duration': '2.5s' }}
|
|
119
|
+
duration={2500}
|
|
120
|
+
afterShow={() => {
|
|
121
|
+
console.log('afterShow')
|
|
122
|
+
}}
|
|
123
|
+
afterClose={() => {
|
|
124
|
+
console.log('afterClose')
|
|
125
|
+
}}
|
|
126
|
+
/>
|
|
127
|
+
</>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
export default Demo3
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 不锁定背景滚动
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import React, { useState } from 'react'
|
|
139
|
+
import { Button, Overlay } from '@mijadesign/mjui-react-taro'
|
|
140
|
+
|
|
141
|
+
const Demo4 = () => {
|
|
142
|
+
const [visible, setVisible] = useState(false)
|
|
143
|
+
const handleToggleShow = () => {
|
|
144
|
+
setVisible(true)
|
|
145
|
+
}
|
|
146
|
+
const onClose = () => {
|
|
147
|
+
setVisible(false)
|
|
148
|
+
}
|
|
149
|
+
return (
|
|
150
|
+
<>
|
|
151
|
+
<Button type="primary" onClick={handleToggleShow}>
|
|
152
|
+
不锁定背景滚动
|
|
153
|
+
</Button>
|
|
154
|
+
<Overlay visible={visible} onClick={onClose} lockScroll={false} />
|
|
155
|
+
</>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
export default Demo4
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 嵌套内容
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import React, { useState } from 'react'
|
|
167
|
+
import { Button, Overlay } from '@mijadesign/mjui-react-taro'
|
|
168
|
+
|
|
169
|
+
const Demo5 = () => {
|
|
170
|
+
const [visible, setVisible] = useState(false)
|
|
171
|
+
|
|
172
|
+
const wrapperStyle = {
|
|
173
|
+
display: 'flex',
|
|
174
|
+
height: '100%',
|
|
175
|
+
alignItems: 'center',
|
|
176
|
+
justifyContent: 'center',
|
|
177
|
+
}
|
|
178
|
+
const contentStyle = {
|
|
179
|
+
display: 'flex',
|
|
180
|
+
width: '150px',
|
|
181
|
+
height: '150px',
|
|
182
|
+
background: '#fff',
|
|
183
|
+
borderRadius: '8px',
|
|
184
|
+
alignItems: 'center',
|
|
185
|
+
justifyContent: 'center',
|
|
186
|
+
color: 'red',
|
|
187
|
+
}
|
|
188
|
+
const handleToggleShow = () => {
|
|
189
|
+
setVisible(true)
|
|
190
|
+
}
|
|
191
|
+
const onClose = () => {
|
|
192
|
+
setVisible(false)
|
|
193
|
+
}
|
|
194
|
+
return (
|
|
195
|
+
<>
|
|
196
|
+
<Button type="success" onClick={handleToggleShow}>
|
|
197
|
+
嵌套内容
|
|
198
|
+
</Button>
|
|
199
|
+
<Overlay visible={visible} onClick={onClose}>
|
|
200
|
+
<div style={wrapperStyle}>
|
|
201
|
+
<div style={contentStyle}>这里是正文</div>
|
|
202
|
+
</div>
|
|
203
|
+
</Overlay>
|
|
204
|
+
</>
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
export default Demo5
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### 点击遮罩不关闭
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import React, { useState } from 'react'
|
|
216
|
+
import { Button, Overlay } from '@mijadesign/mjui-react-taro'
|
|
217
|
+
|
|
218
|
+
const Demo6 = () => {
|
|
219
|
+
const [visible, setVisible] = useState(false)
|
|
220
|
+
const wrapperStyle = {
|
|
221
|
+
display: 'flex',
|
|
222
|
+
height: '100%',
|
|
223
|
+
alignItems: 'center',
|
|
224
|
+
justifyContent: 'center',
|
|
225
|
+
}
|
|
226
|
+
const contentStyle = {
|
|
227
|
+
display: 'flex',
|
|
228
|
+
width: '150px',
|
|
229
|
+
height: '150px',
|
|
230
|
+
background: '#fff',
|
|
231
|
+
borderRadius: '8px',
|
|
232
|
+
alignItems: 'center',
|
|
233
|
+
justifyContent: 'center',
|
|
234
|
+
color: 'red',
|
|
235
|
+
}
|
|
236
|
+
const handleToggleShow = () => {
|
|
237
|
+
setVisible(true)
|
|
238
|
+
}
|
|
239
|
+
const onClose = () => {
|
|
240
|
+
setVisible(false)
|
|
241
|
+
}
|
|
242
|
+
return (
|
|
243
|
+
<>
|
|
244
|
+
<Button type="primary" onClick={handleToggleShow}>
|
|
245
|
+
点击遮罩不关闭
|
|
246
|
+
</Button>
|
|
247
|
+
<Overlay visible={visible} closeOnOverlayClick={false}>
|
|
248
|
+
<div style={wrapperStyle}>
|
|
249
|
+
<div style={contentStyle} onClick={onClose}>
|
|
250
|
+
这里是正文
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</Overlay>
|
|
254
|
+
</>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
export default Demo6
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Overlay
|
|
262
|
+
|
|
263
|
+
### Props
|
|
264
|
+
|
|
265
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
266
|
+
| --- | --- | --- | --- |
|
|
267
|
+
| visible | 当前组件是否显示 | `boolean` | `false` |
|
|
268
|
+
| duration | 动画时长,单位毫秒 | `number` | `300` |
|
|
269
|
+
| lockScroll | 背景是否锁定 | `boolean` | `true` |
|
|
270
|
+
| zIndex | 设置组件页面层级 | `number` | `1000` |
|
|
271
|
+
| closeOnOverlayClick | 是否点击遮罩关闭 | `boolean` | `true` |
|
|
272
|
+
| onClick | 点击时触发 | `event: Event` | `-` |
|
|
273
|
+
| afterClose | 完全关闭后触发 | `() => void` | `-` |
|
|
274
|
+
| afterShow | 完全展示后触发 | `() => void` | `-` |
|
|
275
|
+
|
|
276
|
+
## 主题定制
|
|
277
|
+
|
|
278
|
+
### 样式变量
|
|
279
|
+
|
|
280
|
+
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 [ConfigProvider 组件](#/zh-CN/component/configprovider)。
|
|
281
|
+
|
|
282
|
+
| 名称 | 说明 | 默认值 |
|
|
283
|
+
| --- | --- | --- |
|
|
284
|
+
| \--nutui-overlay-bg-color | 遮罩层背景颜色 | `$color-mask` |
|
|
285
|
+
| \--nutui-overlay-zIndex | overlay 的 z-index | `1000` |
|
|
286
|
+
| \--nutui-overlay-content-bg-color | 遮罩层嵌套内容背景颜色 | `$white` |
|
|
287
|
+
| \--nutui-overlay-content-color | 遮罩层嵌套内容字体颜色 | `$color-title` |
|
|
288
|
+
| \--nutui-overlay-animation-duration| 遮罩层动画延时的时长 | `0.3s` |
|