杨川
杨川
  • 发布:2025-01-20 14:48
  • 更新:2025-01-20 14:57
  • 阅读:77

【报Bug】uniappx ‌error: undefined is not a function (near '...uni.setClipboardData...')‌

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: MacOS Monterey 12.7.5

HBuilderX类型: 正式

HBuilderX版本号: 4.45

手机系统: iOS

手机系统版本号: iOS 16

手机厂商: 苹果

手机机型: iPhone8 P

页面类型: nvue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

uni.setClipboardData({
data: item.name + " " + item.pinyin,
showToast: true,
success: function() {
uni.showToast({
icon: "none",
title: "Copy success"
})
},
fail: function() {
uni.showToast({
icon: "none",
title: "Copy fail"
})
}
})

操作步骤:
uni.setClipboardData({  
                        data: "testcc",  
                        showToast: true,  
                        success: function() {  
                            uni.showToast({  
                                icon: "none",  
                                title: "Copy success"  
                            })  
                        },  
                        fail: function() {  
                            uni.showToast({  
                                icon: "none",  
                                title: "Copy fail"  
                            })  
                        }  
                    })

预期结果:
uni.setClipboardData({  
                        data: "testcc",  
                        showToast: true,  
                        success: function() {  
                            uni.showToast({  
                                icon: "none",  
                                title: "Copy success"  
                            })  
                        },  
                        fail: function() {  
                            uni.showToast({  
                                icon: "none",  
                                title: "Copy fail"  
                            })  
                        }  
                    })

实际结果:
error: undefined is not a function (near '...uni.setClipboardData...')‌

bug描述:

真机上运行,运行的基座是重新打包过的,uni.setClipboardData 这个函数不存在。但是api 文档中是有这个函数的,所以很奇怪为什么不存在!

2025-01-20 14:48 负责人:无 分享
已邀请:
杨川

杨川 (作者) - 小小开发者

uniappx uvue 页面中无法使用 uni.setClipboardData 函数,uniappx 开发文档中是有的

蔡cai

蔡cai - 开发的插件:https://ext.dcloud.net.cn/publisher?id=394134

要回复问题请先登录注册