Vue项目报错: “TypeError: Cannot read properties of undefined (reading ‘init‘)“
[Vue warn]: Error in mounted hook: "TypeError: Cannot read properties of undefined (reading 'init')"
·
目录
背景
在Vue项目中引入echarts插件,发现如下报错:
[Vue warn]: Error in mounted hook: "TypeError: Cannot read properties of undefined (reading 'init')"
在组件中引入的方式是:按需引入
// 引入echarts
import echarts from 'echarts';
export default {
name:"",
mounted() {
// 初始化echarts实例
let lineCharts = echarts.init(this.$refs.charts);//按需引入
}
解决方法
改变引入方法
import * as echarts from 'echarts';
更多推荐
已为社区贡献6条内容
所有评论(0)