# 解決 ECharts + vue-echarts 的 dataset 無法渲染的問題 ## TL;DR 沒想到連 **Dataset** 本身也是一個 component,所以要記得匯入並 `use` 它。 ```typescript= // <script setup lang="ts"> import { computed } from 'vue' import { type EChartsOption } from 'echarts' import { use } from 'echarts/core' import { DatasetComponent } from 'echarts/components' import VueECharts from 'vue-echarts' use([ DatasetComponent, ..., ]) const option = computed<EChartsOption>(() => ({ dataset: { ... }, series: { ... }, })) ``` 如果並不在意打包大小,那麼也可以直接一次匯入所有 component,就不需要再呼叫 `use()` 了。 ```typescript= import "echarts" ``` ## 官方文件 - https://echarts.apache.org/handbook/en/basics/import/ - https://github.com/ecomfe/vue-echarts
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up