收藏
回答

微信公众号H5点击自定义按钮保存图片到本地吗?

    let timer;
    html2canvas(document.querySelector("#header-top")).then(canvas => {

      var img = canvas.toDataURL("image/png");
      //  清除可能的延时器
    clearTimeout(timer);
      var btnsloads = document.getElementById('btnsloads');
      btnsloads.addEventListener('touchstart', function (e) {
        timer = setTimeout(() => {
          console.log('长按事件触发');
          // 在这里执行长按的逻辑
      }, 500); // 延时时间可以根据需要调整
      });
      btnsloads.addEventListener('touchend', function (e: any) {
        clearTimeout(timer);
      });


    });


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

1 个回答

  • hello world
    hello world
    2025-05-08

    wx.downloadImage({

      serverId: '', // 需要下载的图片的服务器端ID,由uploadImage接口获得

      isShowProgressTips: 1, // 默认为1,显示进度提示

      success: function (res) {

        var localId = res.localId; // 返回图片下载后的本地ID

      }

    });


    只能如此

    2025-05-08
    有用 1
    回复
登录 后发表内容