wechat-miniprogram / wechat-miniprogram/api-typings

onShareTimeline(): ICustomTimelineContent | void 没有支持promise参数

Open
#373 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
803
Forks
117
Avg merge
24m
Merged PRs (30d)
1

Description

onShareTimeline()
基础库 2.11.3 开始支持,低版本需做兼容处理

详见分享到朋友圈

监听右上角菜单“分享到朋友圈”按钮的行为,并自定义分享内容。

注意:只有定义了此事件处理函数,右上角菜单才会显示“分享到朋友圈”按钮

自定义转发内容

事件处理函数返回一个 Object,用于自定义分享内容,不支持自定义页面路径,返回内容如下:

字段 说明 默认值 最低版本
title 自定义标题,即朋友圈列表页上显示的标题 当前小程序名称
query 自定义页面路径中携带的参数,如 path?a=1&b=2 的 “?” 后面部分 当前页面路径携带的参数
imageUrl 自定义图片路径,可以是本地文件或者网络图片。支持 PNG 及 JPG,显示图片长宽比是 1:1。 默认使用小程序 Logo
promise 如果该参数存在,则以 resolve 结果为准,如果三秒内不 resolve,分享会使用上面传入的默认参数 3.12.0
示例代码

Page({
onShareTimeline() {
const promise = new Promise(resolve => {
setTimeout(() => {
resolve({
title: '自定义转发标题'
})
}, 2000)
})
return {
title: '自定义转发标题',
query: 'id=123',
imageUrl: '/images/share.png',
promise
}
}
})

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the TypeScript declaration for onShareTimeline and compare its return type with the documented fields in the issue, especially promise. Update the declaration to represent the documented API and run the repository's existing type-check or test commands to confirm the typing accepts the example usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.