Taro 小程序分享到朋友圈

2021-12-07  本文已影响0人  我是Msorry

参考 Taro hooks

// 分享注册
  wx.showShareMenu({
    withShareTicket: true,
    menus: ['shareAppMessage', 'shareTimeline']
  })
// 配置 button 分享
  Taro.useShareAppMessage(res => {
    if (res.from === "button") {
      // 来自页面内转发按钮
      console.log(res.target);
    }
    return {
      title: "圣诞贺卡",
      imageUrl: "", // 图片 URL
      path: "/pages/christmas/index"
    };
  });
// 配置分享到朋友圈
  Taro.useShareTimeline(res=>{
    return {
      title: "圣诞贺卡",
      query: "", 
      imageUrl: 
    };
  })
// index.config.ts
export default {
  // 当 `onShareAppMessage` 没有触发时,可以尝试配置此选项
  enableShareAppMessage: true
}
上一篇 下一篇

猜你喜欢

热点阅读