forked from tangly1024/NotionNext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelect.js
40 lines (37 loc) · 902 Bytes
/
Select.js
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
39
40
import React from 'react'
/**
* 下拉单选框
*/
class Select extends React.Component {
constructor (props) {
super(props)
this.handleChange = this.handleChange.bind(this)
}
handleChange (event) {
const { onChange } = this.props
onChange(event.target.value)
}
render () {
return (
<div className='py-1 space-x-3'>
<label className='text-gray-500'>{this.props.label}</label>
<select value={this.props.value} onChange={this.handleChange} className='border p-1 rounded cursor-pointer'>
{this.props.options?.map(o => (
<option key={o.value} value={o.value}>
{o.text}
</option>
))}
</select>
</div>
)
}
}
Select.defaultProps = {
label: '',
value: '1',
options: [
{ value: '1', text: '选项1' },
{ value: '2', text: '选项2' }
]
}
export default Select