小程序不能分享和转发?求index.ts和app.ts中相关代码

小程序 文章 2022-04-22 17:40 359 0 全屏看文

AI助手支持GPT4.0

小程序不能分享和转发?求index.ts和app.ts中相关代码Can't share and forward mini programs? Find the relevant code in index.ts and app.ts

小程序不能分享和转发?求index.ts和app.ts中相关代码

如图:本人想把wap网站封装成微信小程序,封装之后发现分享到朋友圈和转发给朋友的相关功能不能使用。求index.ts 和 app.ts中相关转发与分享代码。(注意不是index.js 和 app.js代码,这个网上有,但是新建的小程序里面是 index.ts 和 app.ts 文件)

As shown in the figure: I want to package the WAP website into a wechat applet. After packaging, I find that the related functions of sharing to the circle of friends and forwarding to friends cannot be used. Find index Ts and app TS related forwarding and sharing code. (note that it is not the code of index.js and app.js, which are available on the Internet, but the new applet contains the files of index.ts and app.ts)

回答:

less:

js VS ts

跨商通:

1、新建一个page,不要改任何代码,然后点击分享。

鲤子:

index.ts里面加个转发的方法onShareAppMessage

习令奋:谢谢你  刚刚看了一下文档 


Page({
  onShareAppMessage() {
    const promise = new Promise(resolve => {
      setTimeout(() => {
        resolve({
          title: '自定义转发标题'
        })
      }, 2000)
    })
    return {
      title: '自定义转发标题',
      path: '/page/user?id=123',
      promise
    }
  }
})


请问 title 和 path 怎么设置。默认好像是小程序名称和首页。我希望是当前页面的标题和地址。怎么设置呢?
拾忆:如果希望是默认的,里面的代码就都不要,只保留下面的就行。
嘿嘿:

onShareAppMessage

习令奋:谢谢  请问 title 和 path 怎么设置。默认好像是小程序名称和首页。我希望是当前页面的标题和地址。怎么设置呢?   
    title: '自定义转发标题',
      path: '/page/user?id=123',
微喵网络:

要在页面代码中配置onShareAppMessage

-EOF-

AI助手支持GPT4.0