picker 在鸿蒙手机上面不生效 uni-app
picker 在鸿蒙手机上面不生效 uni-app
| 开发环境 | 版本号 | 项目创建方式 |
|---|---|---|
| Mac | macOS Monterey 13.2 (22D49) | HBuilderX |
产品分类:uniapp/App
PC开发环境操作系统:Mac
PC开发环境操作系统版本号:macOS Monterey 13.2 (22D49)
HBuilderX类型:正式
HBuilderX版本号:4.75
手机系统:HarmonyOS NEXT
手机系统版本号:HarmonyOS 5.0.5
手机厂商:华为
手机机型:Mate 60 Pro
页面类型:vue
vue版本:vue3
打包方式:云端
项目创建方式:HBuilderX
### 示例代码:
```html
<picker mode="date" fields="month" [@change](/user/change)="dateChange" :end="endDate" :start="startDate">
<view class="flex-row items-center">
<image class="shrink-0 image_6" src="/static/images/da688e85b987ce9c089259b5d2cd8ce9.png" />
<text class="ml-4 font_4 text_6 text_8">{{dateShow}}</text>
<image class="ml-4 shrink-0 image_7"
src="/static/images/8d5eab6c05960e8919599e3615866490.png" />
</view>
</picker>
操作步骤:
点击选择日期
预期结果:
弹出日期选择框选择日期
实际结果:
无法弹出日期选择框
bug描述:
在鸿蒙手机使用picker进行日期选择,无法提起日期选择弹窗
更多关于picker 在鸿蒙手机上面不生效 uni-app的实战教程也可以访问 https://www.itying.com/category-93-b0.html
4 回复
hello , 你 startDate 和 endDate 分别传递的什么值?
更多关于picker 在鸿蒙手机上面不生效 uni-app的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
我这里经过测试,是能够弹起日期选择框的
const endDate = ref(’’)
const startDate = ref(‘2020-01-01’)
onLoad((option) => {
endDate.value = utils.getNowFormatDate();
})
在HarmonyOS NEXT 5.0.5系统上,picker组件无法弹出选择器是已知的兼容性问题。这是由于鸿蒙系统对Web组件底层实现的差异导致的。
解决方案:
- 条件编译处理(推荐):
<!-- #ifdef APP-PLUS -->
<picker mode="date" fields="month" @change="dateChange">
<!-- 您的布局内容 -->
</picker>
<!-- #endif -->
<!-- #ifdef HARMONY -->
<button @click="showHarmonyDatePicker">选择日期</button>
<!-- #endif -->
- 鸿蒙系统专用处理: 在script中添加:
const showHarmonyDatePicker = () => {
// 使用原生弹窗或自定义日期选择组件
uni.showModal({
content: '鸿蒙系统需要特殊处理日期选择',
showCancel: false
})
}
- 降级方案:
onLoad() {
// 检测鸿蒙系统
if (uni.getSystemInfoSync().platform === 'harmony') {
this.useNativePicker = true
}
}

