Tag:微信小程序javascript
Article From:https://segmentfault.com/q/1010000012149506
Question:
toPhoto: function () {
    const ctx = wx.createCanvasContext('myCanvas');
    var that = this;
    wx.chooseImage({
      count: 1, // Default 9SizeType: ['original','compressed'], / / can be specified as original or compressed graph, and the default is the two one.SourceType: ['album','Camera'], / / can specify whether the source is album or camera, and the default is two.Success: function (RES) {That.setData ({ISMod: false,IsCut: true,BgColor: "black",TempFilePaths:res.tempFilePaths[0]})Var tempFilePaths = res.tempFilePaths[0];Wx.getSystemInfo ({Success: function (RES) {That.setData ({Width: res.windowWidth,Height: res.windowHeight,LastX: res.windowWidth * 0.23,LasTY: 0})}})Ctx.save ()Ctx.beginPath ()Ctx.sEtFillStyle ('white');Ctx.fillRect (that.data.width * 0.1, 30, that.data.width * 0.8, that.daTa.height * 0.3);Ctx.clip ();Ctx.drawImage (that.data.tempFilePaths, that.data.width)* 0.23, 0, 200, 300)Ctx.restore ()Ctx.draw ();}})},

Answer 0:

It’s probably because the WeChat version is low

canvasContext.clip

The base library 1.6.0 starts to support, and the low version needs to be compatible.

stayapp.jsAonLaunchHere, this is the code that I use to check the version:

wx.getSystemInfo({
    success: function (res) {
        // check sdk version
        console.log('SDKVersion:' + res.SDKVersion)
        if (res.SDKVersion < '1.6.0') {
            wx.showModal({
                title: 'Hint ',ShowCancel: false,Content: 'current WeChat version is too low to use some functions. Please upgrade to the latest WeChat version and try again. ''})}},})See if it's because you haven't updated WeChat for too long.

Leave a Reply

Your email address will not be published. Required fields are marked *