Canvas2D在onLoad中设置画布大小无效?
因为需要根据机型动态设置画布大小,发现在onLoad中设置无效,请问这种情况我需要怎么设置呢
wxml
<canvas bind:start="start" id="canvas" graph="{{graph}}" width="{{canvasWidth}}" height="{{canvasheight}}" enableUndo="{{true}}"></canvas>
js
data: {
canvasWidth: "650",
canvasheight: "1170",
},
onLoad: function (options) {
const sysInfo = wx.getSystemInfoSync();
const screenHeight = sysInfo.screenHeight
if (screenHeight < 750) {
this.setData({
canvasheight: 900,
canvasWidth: 500
})
} else {
this.setData({
canvasheight: 1170,
canvasWidth: 650
})
}
},