echarts按需引入报错Error in mounted hook: "Error: Component series.bar not exists. Load it first."

原因:

bar组件需要单独引入

方案:

require('echarts/lib/chart/bar')

例子

main.js中

//引入基本模板
let echarts = require('echarts/lib/echarts')


Vue.prototype.$echarts = echarts

蜡烛图组件中

// 引入折线图等组件
  require('echarts/lib/chart/candlestick')
   require('echarts/lib/chart/bar')
  // 引入提示框和title组件,图例
  require('echarts/lib/component/dataset')
  require('echarts/lib/component/title')
  require('echarts/lib/component/tooltip') 
  require('echarts/lib/component/toolbox') 
  require('echarts/lib/component/grid') 
  require('echarts/lib/component/dataZoom') 
  require('echarts/lib/component/visualMap')

 

你可能感兴趣的:(echarts)