-
Notifications
You must be signed in to change notification settings - Fork 296
Expand file tree
/
Copy pathdemo3.tsx
More file actions
38 lines (35 loc) · 850 Bytes
/
demo3.tsx
File metadata and controls
38 lines (35 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React, { useState } from 'react'
import { ActionSheet, Cell } from '@nutui/nutui-react'
const Demo = () => {
const [isVisible, setIsVisible] = useState(false)
const [val, setVal] = useState('')
const options = [
{
name: '分享给朋友',
},
{
name: '添加到收藏夹',
},
]
const handleSelect = (item: any) => {
setVal(item.name)
setIsVisible(false)
}
return (
<>
<Cell onClick={() => setIsVisible(!isVisible)}>
<span>顶部弹出</span>
<div style={{ marginInlineStart: '10px', color: '#999' }}>{val}</div>
</Cell>
<ActionSheet
position="top"
visible={isVisible}
title="标题"
options={options}
onSelect={handleSelect}
onCancel={() => setIsVisible(false)}
/>
</>
)
}
export default Demo