在使用vue+echarts时报错Cannot read property 'init' of underfined。
试了一下网络上的几种方法发现没有。
最后发现:
1.安装echarts项目依赖时要先进入项目文件夹环境(-_-||)。
cd 项目文件路径
//例如 cd D:\project
npm install echarts --save
2.在import时要用单引号import echarts from 'echarts',不要用双引号import echarts from "echarts"。
犯这种错误的我真傻Orz。
原步骤
https://www.cnblogs.com/rose-sharon/p/11755418.html
注意原文就犯了使用双引号的错误
1. 安装echarts项目依赖 npm install echarts --save 2. 在main.js中全局引入 import echarts from "echarts"; Vue.prototype.$echarts = echarts;
<template> <div id="app"> <div id="main" style="width: 600px;height:400px;">&