Description
NutUI React 包名
@nutui/nutui-react-taro
NutUI React 版本号
3.0.2
平台
weapp
重现链接
没有链接,就是官方的Demo示例
重现步骤
import React, { useState } from 'react'
import {
Picker,
Cell,
PickerOptions,
PickerValue,
PickerOnChangeCallbackParameter,
PickerOption,
} from '@nutui/nutui-react-taro'
const Index = () => {
const [visible, setVisible] = useState(false)
const [baseDesc, setBaseDesc] = useState('')
const options = [
[
{ value: 1, label: '南京市' },
{ value: 2, label: '无锡市' },
{ value: 3, label: '海北藏族自治区' },
{ value: 4, label: '北京市' },
{ value: 5, label: '连云港市' },
{ value: 8, label: '大庆市' },
{ value: 9, label: '绥化市' },
{ value: 10, label: '潍坊市' },
{ value: 12, label: '乌鲁木齐市' },
],
]
const changePicker = ({
value,
index,
selectedOptions,
}: PickerOnChangeCallbackParameter) => {
console.log('changePicker', value, index, selectedOptions)
}
const confirmPicker = (
selectedOptions: PickerOptions,
selectedValue: PickerValue[]
) => {
console.log('confirmPicker', selectedOptions, selectedValue)
let description = ''
selectedOptions.forEach((option: PickerOption) => {
description += ${option.label}
})
setBaseDesc(description)
}
return (
<>
<Cell
title="请选择城市"
description={baseDesc}
onClick={() => setVisible(!visible)}
/>
<Picker
title="请选择城市"
visible={visible}
options={options}
onConfirm={confirmPicker}
onClose={() => setVisible(false)}
onChange={changePicker}
/>
</>
)
}
export default Index
期望的结果是什么?
样式上每一条选中的数据都只有一条数据,跟手机端一样,而不是除了当前选中值还有上下两个的值
实际的结果是什么?
这个就是官方的例子,但是放在项目中,使用ipad打开,就会变成下面的样子:
环境信息
Taro CLI 3.6.35 environment info:
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 23.8.0 - C:\Program Files\nodejs\node.EXE
npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@tarojs/cli: 3.6.35 => 3.6.35
@tarojs/components: 3.6.35 => 3.6.35
@tarojs/helper: 3.6.35 => 3.6.35
@tarojs/plugin-framework-react: 3.6.35 => 3.6.35
@tarojs/plugin-html: 3.6.35 => 3.6.35
@tarojs/plugin-platform-alipay: 3.6.35 => 3.6.35
@tarojs/plugin-platform-h5: 3.6.35 => 3.6.35
@tarojs/plugin-platform-jd: 3.6.35 => 3.6.35
@tarojs/plugin-platform-qq: 3.6.35 => 3.6.35
@tarojs/plugin-platform-swan: 3.6.35 => 3.6.35
@tarojs/plugin-platform-tt: 3.6.35 => 3.6.35
@tarojs/plugin-platform-weapp: 3.6.35 => 3.6.35
@tarojs/react: 3.6.35 => 3.6.35
@tarojs/runtime: 3.6.35 => 3.6.35
@tarojs/shared: 3.6.35 => 3.6.35
@tarojs/taro: 3.6.35 => 3.6.35
@tarojs/taro-loader: 3.6.35 => 3.6.35
@tarojs/webpack5-runner: 3.6.35 => 3.6.35
babel-preset-taro: 3.6.35 => 3.6.35
eslint-config-taro: 3.6.35 => 3.6.35
react: ^18.0.0 => 18.3.1
其他补充信息
No response