收藏
回答

wx.shareToOfficialAccount报错be invoked by user TAP?

小程序调用wx.shareToOfficialAccount,报错;fail can only be invoked by user TAP gesture, 

其它小程序能正常调用,是不是小程序还需要做设置之类的,wxba6543bb3afada5c则报错

数据是正常,方法如下

  async onShareOffcialAccount() {
    const imgurls = this.data.selectedImages.filter(item => item.selected)
    const tempPaths = await fileManager.downloadImages(imgurls.map(item => item.url),{saveToAlbum:false});
    const that = this
    if (stringIsEmpty(this.data.content) || stringIsEmpty(this.data.title) || stringIsEmpty(officialPath)) {
      that.showTip('题目、正文、话题须填写!')
      return
    }
    //  文档 https://blog.minapper.com/12312.html
    wx.shareToOfficialAccount({
      title: this.data.title,
      content: this.data.content,
      tags: this.data.selectedTags,
      path: officialPath,
      images: tempPaths,
      success: (res) => {
        that.showTip('公众号文章发布成功')
      },
      fail: (err) => {
        // 用户主动退出图文编辑器时触发
        console.log(err)
      },
      complete: (res) => {
        // 统计接口总共调用次数
        console.log(res)
      },
    })
  },

回答关注问题邀请回答
收藏

3 个回答

  • 智能回答 智能回答 本次回答由AI生成
    02-11
    有用 2
    回复 2
    • 凯哥说服装零售赋能
      凯哥说服装零售赋能
      02-13
      JS 和 wxml ,同样的代码,在另外一个小程序正常的,
      具体如下:
        <button  bindtap="onShareOffcialAccount">去发布公众号<button>
      02-13
      回复
    • 凯哥说服装零售赋能
      凯哥说服装零售赋能
      02-13
      fileManager.downloadImages:这个方法有问题
      02-13
      回复
  • sun
    sun
    发表于小程序端
    02-11

    这个报错的意思是,该方法仅能通过用户点击触发。

    02-11
    有用
    回复
  • 一笑皆春
    一笑皆春
    02-11

    必须用户点击,而且不能在异步回调里

    02-11
    有用
    回复
登录 后发表内容