vue+echarts报错Cannot read property ‘init‘ of underfined

在整合Vue和Echarts时遇到'Cannot read property 'init' of undefined'错误。问题根源在于安装依赖时需在项目文件夹内执行,并且在导入Echarts时,需使用单引号import echarts from 'echarts'而非双引号。
摘要由CSDN通过智能技术生成

在使用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;">&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值