-
Notifications
You must be signed in to change notification settings - Fork 296
Expand file tree
/
Copy pathdemo2.tsx
More file actions
38 lines (35 loc) · 855 Bytes
/
demo2.tsx
File metadata and controls
38 lines (35 loc) · 855 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 [val, setVal] = useState('')
const [isVisible, setIsVisible] = useState(false)
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
title="标题"
visible={isVisible}
options={options}
onSelect={handleSelect}
onCancel={() => setIsVisible(false)}
cancelText="取消"
/>
</>
)
}
export default Demo