diff --git a/README.md b/README.md index a53b3818c0d19178542c07d3b4e527b1eee3b255..2577608976aa4b05d9930a15b68433db93194dac 100644 --- a/README.md +++ b/README.md @@ -136,8 +136,8 @@ setup() { ## 优化方向 -* 部分图表选择展示的内容会报错,怀疑是配置问题。 * 地图组件由于 `Vue3` 无法直接通过 ref 取到 ECharts 组件内部函数,暂时无法实现自动轮播。 +* Vue 3.0+版本中,修改了 useContext() API,需要进行兼容升级 ## 五、其余 diff --git a/src/utils/useDraw.ts b/src/utils/useDraw.ts index 10779b118a0adc9cda951f36f302210b9b97cfa5..674d3a0bedd5e559b6abb1f4a7365a9be69baf17 100644 --- a/src/utils/useDraw.ts +++ b/src/utils/useDraw.ts @@ -1,6 +1,6 @@ import { ref } from 'vue' -export default function useIndex() { +export default function useDraw() { // * 指向最外层容器 const appRef = ref() // * 定时函数 @@ -46,9 +46,15 @@ export default function useIndex() { window.addEventListener('resize', resize) } + // 改变窗口大小重新绘制 + const unWindowDraw = () => { + window.removeEventListener('resize', resize) + } + return { appRef, calcRate, windowDraw, + unWindowDraw } } diff --git a/src/views/bottomLeft/chart/draw.tsx b/src/views/bottomLeft/chart/draw.tsx index 5d1af89126a9e7621d3a45762b52c46697e9cb60..974f4832230248f464d5a9bd50b2545a905fcc33 100644 --- a/src/views/bottomLeft/chart/draw.tsx +++ b/src/views/bottomLeft/chart/draw.tsx @@ -35,11 +35,7 @@ export default defineComponent({ } }, legend: { - data: ["已贯通", "计划贯通", "贯通率"], - textStyle: { - color: "#B4B4B4" - }, - top: "0%" + show: false, }, grid: { x: "8%", diff --git a/src/views/index/index.vue b/src/views/index/index.vue index 0b05f8db9167ceb0ec327d256bce8ff091e6b803..f8977a85688a7ba1b376c17bcbfac655180d7e78 100644 --- a/src/views/index/index.vue +++ b/src/views/index/index.vue @@ -102,7 +102,7 @@ import { } from 'vue' import { formatTime } from '@/utils/index' import { WEEK } from '@/constant/index' -import useIndex from '@/utils/useDraw' +import useDraw from '@/utils/useDraw' import { title, subtitle, moduleInfo } from '@/constant/index' import CenterLeft1 from '../centerLeft1/index.vue' import CenterLeft2 from '../centerLeft2/index.vue' @@ -133,7 +133,7 @@ export default defineComponent({ dateWeek: '' }) // * 适配处理 - const { appRef, calcRate, windowDraw } = useIndex() + const { appRef, calcRate, windowDraw, unWindowDraw } = useDraw() // 生命周期 onMounted(() => { cancelLoading() @@ -144,6 +144,7 @@ export default defineComponent({ }) onBeforeUnmount(() => { + unWindowDraw() clearInterval(timeInfo.setInterval) })