收藏
回答

在小程序webview内嵌的h5页面中调用wx.chooseImage触发刷新页面?

在小程序webview内嵌的h5页面中调用wx.chooseImage拍照触发刷新页面,app.js以及当前页面的onshow里并没有逻辑代码,只有拍照有这个问题,相册没有。是什么原因啊

uploadImage() {
      let that = this;
      if (window.__wxjs_environment === "miniprogram") {
        wx.miniProgram.getEnv(function (res{
          if (res.miniprogram) {
            wx.chooseImage({
              count: that.count,
              successfunction (req{
                that.totalUpload = false
                that.syncUpload(req.localIds)
              },
              fail() {
                Toast.fail("选择图片失败!");
              },
            });
          }
        });
      }
    },
    syncUpload(localIds) {
      const localId = localIds.pop();
      const that = this
      wx.uploadImage({
        localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
        isShowProgressTips0,
        successfunction (resp{
          that.handleUpload2(resp.serverId)
          if(localIds.length > 0){
            that.syncUpload(localIds);
            return
          }else{
            that.totalUpload = true
          }
        }
      });
    },
    handleUpload(data){
      Toast.loading({
        message'正在上传...',
        forbidClicktrue,
        loadingType'spinner',
        duration0
      })
      uploadWxFile({codeName:data}).then(response=>{
        this.fileList.push({
          id: response.fileMidId,
          url: response.fileUrl,
        })
        this.$emit("change"this.fileList)
        if(this.totalUpload){
          Toast.clear()
        }
      }).catch(()=>{
        if(this.totalUpload){
          Toast.clear()
        }
        this.$toast.fail('上传失败!')
      })
    },
回答关注问题邀请回答
收藏

3 个回答

  • 社区技术运营专员--阳光
    社区技术运营专员--阳光
    2021-08-10

    你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

    2021-08-10
    有用
    回复 2
    • Summer
      Summer
      2021-08-16
      机型iphone12,微信版本号:8.0.10,系统版本IOS14.5,通过webview链接到A页面,A页面通过vue-router链接到B页面,在B页面上传(图二,图三)
      2021-08-16
      回复
    • Lumberjack
      Lumberjack
      2021-09-08
      哈喽,解决了吗
      2021-09-08
      回复
  • 七叶树
    七叶树
    2022-03-02

    同遇到这个问题,试过 把sizeType设置为compressed,count设置为1 都没有用。



    2022-03-02
    有用 1
    回复 1
    • A 百变鹏仔 💋
      A 百变鹏仔 💋
      2023-09-27
      你解决没,看你这边是2022年发的了
      2023-09-27
      回复
  • A 百变鹏仔 💋
    A 百变鹏仔 💋
    2023-09-27

    遇到一样的问题

    2023-09-27
    有用
    回复
登录 后发表内容