一个页面不同位置,渲染多个echarts

2022-07-08  本文已影响0人  老板下碗面
      <el-form-item prop="a" :label="'一楼:'">
        <geoJson />
      </el-form-item>
      <el-form-item prop="a" :label="'二楼:'">
        <geoJson />
      </el-form-item>
    //如有页面需要多次调用,使用document.getElementById不能多次初始化,只会显示一个
    //用this.$refs.myChart 或者currentInstance.ctx.$refs.myChart
  import { getCurrentInstance, onMounted } from '@vue/runtime-core'
setup(){

      onMounted(() => {
        currentInstance = getCurrentInstance()
      })

  const initGeo = (num) => {
        var dom = currentInstance.ctx.$refs.myChart
        const myChart = echarts.init(dom)
    }
}
上一篇 下一篇

猜你喜欢

热点阅读