l***@163.com
l***@163.com
  • 发布:2024-07-10 22:19
  • 更新:2024-07-11 10:28
  • 阅读:108

【报Bug】vue3 通过组合函数实现分享 没效果

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 22H2

HBuilderX版本号: 4.08

第三方开发者工具版本号: stable 1.06.2402040

基础库版本号: 3.4.4

项目创建方式: CLI

CLI版本号: 3.0.0-4000720240327002

示例代码:

组合函数
import system from '@/constant/system'
type ShareConfigType = Page.CustomShareContent | Promise<Omit<Page.CustomShareContent, 'promise'>>
type GetShareConfigType = (arg: Page.ShareAppMessageOption) => ShareConfigType
function useShare(_shareConfig?: GetShareConfigType) {
onShareAppMessage((_e) => {
return {
title: system.title,
path: system.homePage,
}
})
return {}
}
export default useShare

index.vue 引入
import useShares from '@/hooks/useShare'
useShares()

操作步骤:

组合函数
import system from '@/constant/system'
type ShareConfigType = Page.CustomShareContent | Promise<Omit<Page.CustomShareContent, 'promise'>>
type GetShareConfigType = (arg: Page.ShareAppMessageOption) => ShareConfigType
function useShare(_shareConfig?: GetShareConfigType) {
onShareAppMessage((_e) => {
return {
title: system.title,
path: system.homePage,
}
})
return {}
}
export default useShare

index.vue 引入
import useShares from '@/hooks/useShare'
useShares()

预期结果:

可以分享

实际结果:

不能分享

bug描述:

uniapp+vue3+ts 编译为微信小程序
组合函数
import system from '@/constant/system'
type ShareConfigType = Page.CustomShareContent | Promise<Omit<Page.CustomShareContent, 'promise'>>
type GetShareConfigType = (arg: Page.ShareAppMessageOption) => ShareConfigType
function useShare(_shareConfig?: GetShareConfigType) {
onShareAppMessage((_e) => {
return {
title: system.title,
path: system.homePage,
}
})
return {}
}
export default useShare

index.vue 引入
import useShares from '@/hooks/useShare'
useShares()

问题index页面分享按钮不能点击??????

2024-07-10 22:19 负责人:无 分享
已邀请:
DCloud_UNI_yuhe

DCloud_UNI_yuhe

你这是主动触发onShareAppMessage?能给出完整代码吗?onShareAppMessage是点击分享后调用

  • l***@163.com (作者)

    一般正常情况页面写了onShareAppMessage((_e) => {

    return {

    title: system.title,

    path: system.homePage,

    }

    })

    点右上角三个点 里面的分享按钮就可以点击


    我用上面组合函数的方式 三个点里面的分享按钮就不可点击


    上面就是两个页面主要逻辑完整代码

    2024-07-11 10:53

要回复问题请先登录注册