下面是 vue 组件下的代码
<template>
<div ref="containerRef" style="width: 100%; height: 400px;"></div>
</template>
<script setup lang="ts">
import { ref, onMounted } from "vue";
import * as echarts from 'echarts';
import 'echarts-gl'
const containerRef = ref<HTMLElement>()
onMounted(function () {
const charts = echarts.init(containerRef.value as HTMLElement)
charts.setOption({
// grid3D: {},
// xAxis3D: {},
// yAxis3D: {},
// zAxis3D: {},
backgroundColor: '#000',
globe: {
}
})
})
</script>
发现 canvas 压根没有渲染出来
这是官方示例
上面使用了全部引入的方式,也使用了 use 的按需引入的方式,也是无法正确渲染出 canvas 元素。
这是使用的版本
"echarts": "^5.4.2",
"echarts-gl": "^2.0.9",
请问在 vue 中应该怎么使用 echarts-gl
没效果的原因是题主压根没写配置呀
最终效果
补充回答:三维柱状图也正常
附上纹理图: