ucharts大坑

用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%,变得可控
    以上例子详情:开发工具正常,预览版和体验版异常的场景
发布了101 篇原创文章 · 获赞 5 · 访问量 3720

猜你喜欢

转载自blog.csdn.net/weixin_41254345/article/details/104413137