|
[云开发]
apiclould使用echarts手机横屏后图表错乱
[复制链接]
在手机横竖屏切换时折线图会变形,也添加了监听,每次取当前屏幕宽高对echart进行resize- window.addEventListener("orientationchange", () => {
- if (window.orientation == 90 || window.orientation == -90) {
- //取小的高度
- var height = api.winWidth > api.winHeight ? api.winHeight : api.winWidth
- var width = api.winWidth < api.winHeight ? api.winHeight : api.winWidth
- this.autoHeight = height - api.safeArea.top - 30
- this.autoWidth = width
- this.$nextTick(() => {
- this.dyChart.resize({
- width: this.autoWidth,
- height: this.autoHeight
- })
- })
- } else if (window.orientation == 0) {
- var height = api.winWidth < api.winHeight ? api.winHeight : api.winWidth
- var width = api.winWidth > api.winHeight ? api.winHeight : api.winWidth
- this.autoHeight = height - api.safeArea.top - 30
- this.autoWidth = width
- this.$nextTick(() => {
- this.dyChart.resize({
- width: this.autoWidth,
- height: this.autoHeight
- })
- })
- }
- }, false);
复制代码
|
-
从竖屏切换横屏
-
横屏时
|