vue引入echarts報錯Cannot read properties of undefined (reading 'init')


下載echarts成功后,按照官方文檔引入echarts:

在組件內引用:

import echarts from 'echarts'

echarts.init(document.getElementById('idname'));

  發現會報錯

 

 idname也檢查過,是存在的對象

解決辦法:1、用require

let echarts = require('echarts');
let myChart = echarts.init(document.getElementById('idname'));

 2、

import * as echarts from 'echarts'
let myChart = echarts.init(document.getElementById('idname'));

  親測可用


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM