用uniapp做小程序,用到了ucharts
但是插件的canvas宽高很不稳定,要用自己的变量才可以,一旦mounted完后,selfWidth 和selfHeight 就固定不变了(稳定了)
mounted() {
let info = uni.getStorageSync('systemInfo')
this.selfWidth = info.windowWidth
this.selfHeight = 504*(info.windowWidth/750)
}
<canvas :canvasId="canvasId" id="canvasId" :style="{ width: selfWidth + 'px', height: selfHeight + 'px' }" @touchstart="touchstart" />
- 修改前
- 修改后
修改后宽高占100%,变得可控
以上例子详情:开发工具正常,预览版和体验版异常的场景