【异常】报错:TypeError: Cannot read properties of undefined (reading ‘init‘)
一、报错内容
在vue当中引用echarts,控制台报错: “TypeError: Cannot read properties of undefined (reading ‘init‘)
二、 报错说明
因为引用了echarts里面的init方法显示没有定义
import {
userStatistics } from "@/api/chart";
import echarts from "echarts";
require("echarts/theme/macarons"); // echarts theme
import resize from "../mixins/resize";
三、报错解决
将import echarts from 'echarts'
的引入方式改为:import * as echarts from 'echarts'
import {
userStatistics } from "@/api/chart";
import * as echarts from 'echarts';
require("echarts/theme/macarons"); // echarts theme
import resize from "../mixins/resize";
控制台不再报错
还没有评论,来说两句吧...