收藏
回答

为什么发布之后不调用wx.canvasToTempFilePath 开发者工具却可以?

//上传

  uploadCanvasImg: function () {

     var that =this;

    if (this.data.linePrack.length == 0{

      wx.showModal({

        title: '提示',

        content: '签名内容不能为空!',

        showCancel: false

      });

      return false;

    }

    console.log'canvas生成图片地址');

    wx.canvasToTempFilePath({

      canvasId: 'handWriting',

      fileType: 'png',

      quality: 1, //图片质量

      success: function(res) {

         console.log(res.tempFilePath, 'canvas生成图片地址');


        //上传

        wx.uploadFile({

          url: app.globalData.host + '/api/upload.action', // 仅为示例,非真实的接口地址

          filePath: res.tempFilePath,

          name: 'filedata',

          method: 'POST',

          header: {

            'content-type': 'application/x-www-form-urlencoded;charset=utf-8'

          },

          


          success(res) {

            console.log(res.data);

            var url = res.data;

            

              that.setData({

                url: res.data,

               

              })

            // do something

          }

        })


      },fail () {

        console.log("fali")

      },


     

    })

    var hiddenName = that.data.hiddenName 

    that.setData({

      hiddenName: !that.data.hiddenName

    })


  },

<canvas class="handWritingdisable-scroll='true'  bindtouchstart="uploadScaleStartbindtouchmove="uploadScaleMove"

      bindtouchend="uploadScaleEndbindtap="mouseDowncanvas-id="handWriting">

    canvas>


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

1 个回答

登录 后发表内容
问题标签