import { View, PickerView, PickerViewColumn } from "@tarojs/components" import Taro from "@tarojs/taro" export interface IndexProps { options: string[] headerTitle?: string selected: string showPicker: boolean setShowPicker: (show:boolean) => void onChange: (value: string) => void children: JSX.Element|JSX.Element[] } const Index = ({selected, showPicker, setShowPicker,onChange, options, headerTitle = '请选择', children }: IndexProps) => { // 处理选择变化 const handleChange = (e:any) => { const { value } = e.detail onChange(options[value[0]]) } // 确认选择 const handleConfirm = () => { setShowPicker(false) Taro.showToast({ title: `已选择: ${selected}`, icon: 'none' }) } return {children} {showPicker && ( setShowPicker(false)}> 取消 {headerTitle} 确定 {/* 单列 PickerView */} {options.map((item) => ( {item} ))} )} } export default Index;