Skip to content

Commit ace8077

Browse files
committed
修改获取dom方法
1 parent f33c050 commit ace8077

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/chart/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { onMounted, getCurrentInstance, defineProps, defineExpose } from 'vue'
2+
import { onMounted, getCurrentInstance, defineProps, defineExpose, ref } from 'vue'
33
44
defineOptions({
55
name: 'WChart'
@@ -38,6 +38,7 @@ const props = defineProps({
3838
})
3939
4040
let chart: { setOption: (arg0: Record<string, any>) => void; resize: () => void }
41+
const wchart = ref(null)
4142
4243
//声明周期函数,自动执行初始化
4344
onMounted(() => {
@@ -49,8 +50,7 @@ onMounted(() => {
4950
//初始化函数
5051
function init() {
5152
// 基于准备好的dom,初始化echarts实例
52-
const { ctx } = getCurrentInstance() as any
53-
const dom = ctx.$refs['wchart']
53+
const dom = wchart.value
5454
// 通过 internalInstance.appContext.config.globalProperties 获取全局属性或方法
5555
let internalInstance = getCurrentInstance()
5656
let echarts = internalInstance?.appContext.config.globalProperties.$echarts

0 commit comments

Comments
 (0)