uni.setClipboardData({
data: this.data,
success() {
uni.showToast({
title: "复制成功",
})
}
})
- 发布:2024-03-30 15:04
- 更新:2024-03-30 15:10
- 阅读:230
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win11
HBuilderX类型: 正式
HBuilderX版本号: 4.07
手机系统: Android
手机系统版本号: Android 13
手机厂商: 模拟器
手机机型: 模拟器呀
页面类型: vue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
uni.setClipboardData({
data: this.data,
success() {
uni.showToast({
title: "复制成功",
})
}
})
uni.setClipboardData({
data: this.data,
success() {
uni.showToast({
title: "复制成功",
})
}
})
预期结果:
预期是没有任何报错的,只是copy 一下字符串而已
预期是没有任何报错的,只是copy 一下字符串而已
实际结果:
提示如下
[WEB] 类型“Uni”上不存在属性“setClipboardData”。
[APP-ANDROID] 类型“Uni”上不存在属性“setClipboardData”。
编译器报错如下
15:01:22.789 [plugin:uni:app-uts] 编译失败
15:01:22.789 error: Unresolved reference: setClipboardData
15:01:22.789 at pages/index/index.uvue:62:8
15:01:22.789 60 | },
15:01:22.789 61 | copy() {
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 | ^
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 error: Unresolved reference: uni_setClipboardData
15:01:22.789 at pages/index/index.uvue:62:4
15:01:22.789 60 | },
15:01:22.789 61 | copy() {
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 | ^
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 error: Unresolved reference: SetClipboardDataOptions
15:01:22.789 at pages/index/index.uvue:62:4
15:01:22.789 60 | },
15:01:22.789 61 | copy() {
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 | ^
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 error: Cannot infer a type for this parameter. Please specify it explicitly.
15:01:22.789 at pages/index/index.uvue:64:5
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 | ^
15:01:22.789 65 | uni.showToast({
15:01:22.789 66 | title: "复制成功",
提示如下
[WEB] 类型“Uni”上不存在属性“setClipboardData”。
[APP-ANDROID] 类型“Uni”上不存在属性“setClipboardData”。
编译器报错如下
15:01:22.789 [plugin:uni:app-uts] 编译失败
15:01:22.789 error: Unresolved reference: setClipboardData
15:01:22.789 at pages/index/index.uvue:62:8
15:01:22.789 60 | },
15:01:22.789 61 | copy() {
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 | ^
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 error: Unresolved reference: uni_setClipboardData
15:01:22.789 at pages/index/index.uvue:62:4
15:01:22.789 60 | },
15:01:22.789 61 | copy() {
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 | ^
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 error: Unresolved reference: SetClipboardDataOptions
15:01:22.789 at pages/index/index.uvue:62:4
15:01:22.789 60 | },
15:01:22.789 61 | copy() {
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 | ^
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 error: Cannot infer a type for this parameter. Please specify it explicitly.
15:01:22.789 at pages/index/index.uvue:64:5
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 | ^
15:01:22.789 65 | uni.showToast({
15:01:22.789 66 | title: "复制成功",
bug描述:
提示如下
[WEB] 类型“Uni”上不存在属性“setClipboardData”。
[APP-ANDROID] 类型“Uni”上不存在属性“setClipboardData”。
编译器报错如下
15:01:22.789 [plugin:uni:app-uts] 编译失败
15:01:22.789 error: Unresolved reference: setClipboardData
15:01:22.789 at pages/index/index.uvue:62:8
15:01:22.789 60 | },
15:01:22.789 61 | copy() {
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 | ^
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 error: Unresolved reference: uni_setClipboardData
15:01:22.789 at pages/index/index.uvue:62:4
15:01:22.789 60 | },
15:01:22.789 61 | copy() {
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 | ^
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 error: Unresolved reference: SetClipboardDataOptions
15:01:22.789 at pages/index/index.uvue:62:4
15:01:22.789 60 | },
15:01:22.789 61 | copy() {
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 | ^
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 error: Cannot infer a type for this parameter. Please specify it explicitly.
15:01:22.789 at pages/index/index.uvue:64:5
15:01:22.789 62 | uni.setClipboardData({
15:01:22.789 63 | data: this.data,
15:01:22.789 64 | success() {
15:01:22.789 | ^
15:01:22.789 65 | uni.showToast({
15:01:22.789 66 | title: "复制成功",
1 个回复
喜欢技术的前端 - QQ---445849201
uniappx 中 试试 https://ext.dcloud.net.cn/plugin?id=14676