帖子
帖子
用户
博客
课程
显示全部楼层
6
帖子
0
勋章
44
Y币

[云开发] apiclould使用echarts手机横屏后图表错乱

[复制链接]
发表于 2022-3-16 15:58:58
在手机横竖屏切换时折线图会变形,也添加了监听,每次取当前屏幕宽高对echart进行resize
  1. window.addEventListener("orientationchange", () => {
  2.                                         if (window.orientation == 90 || window.orientation == -90) {
  3.                                                 //取小的高度
  4.                                                 var height = api.winWidth > api.winHeight ? api.winHeight : api.winWidth
  5.                                                 var width = api.winWidth < api.winHeight ? api.winHeight : api.winWidth
  6.                                                 this.autoHeight = height - api.safeArea.top - 30
  7.                                                 this.autoWidth = width
  8.                                                 this.$nextTick(() => {
  9.                                                         this.dyChart.resize({
  10.                                                                 width: this.autoWidth,
  11.                                                                 height: this.autoHeight

  12.                                                         })
  13.                                                 })

  14.                                         } else if (window.orientation == 0) {
  15.                                                 var height = api.winWidth < api.winHeight ? api.winHeight : api.winWidth
  16.                                                 var width = api.winWidth > api.winHeight ? api.winHeight : api.winWidth
  17.                                                 this.autoHeight = height - api.safeArea.top - 30
  18.                                                 this.autoWidth = width
  19.                                                 this.$nextTick(() => {
  20.                                                         this.dyChart.resize({
  21.                                                                 width: this.autoWidth,
  22.                                                                 height: this.autoHeight
  23.                                                         })
  24.                                                 })
  25.                                         }

  26.                                 }, false);
复制代码

从竖屏切换横屏

从竖屏切换横屏

横屏时

横屏时
切换成横屏的时候,重新open一下,完后设置宽高
6
帖子
0
勋章
44
Y币
open当前页面吗
特特法爷 · 2022-3-16 16:20切换成横屏的时候,重新open一下,完后设置宽高
是的
6
帖子
0
勋章
44
Y币
您的意思是重新打开当前页面,并且将参数传过来,然后关掉之前的页面吗
6
帖子
0
勋章
44
Y币
打开当前页面后,然后重新查一次
HU_JIE · 2022-3-16 16:46您的意思是重新打开当前页面,并且将参数传过来,然后关掉之前的页面吗
恩,你试下这样行不,完后重新设置宽高
6
帖子
0
勋章
44
Y币
可以的,谢谢大佬,问题解决了,就是每次都要重新查一遍,感觉这个方法不是很聪明
特特法爷 · 2022-3-16 17:11恩,你试下这样行不,完后重新设置宽高
先用着,以后有好的想法可以优化
您需要登录后才可以回帖 登录

本版积分规则