vueにechartsを導入

947 ワード

一.簡単に述べる
vueプロジェクトではアイコンライブラリechartsを使用します.
二.ステップ
  • echarts:npm install echarts-s参照
  • echartsの構成:
  • // The Vue build version to load with the `import` command
    // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
    import Vue from 'vue'
    import App from './App'
    import router from './router'
    import elementUI from 'element-ui'
    import 'element-ui/lib/theme-chalk/index.css'
    import echarts from 'echarts'
    
    Vue.use(echarts)
    Vue.use(elementUI)
    Vue.config.productionTip = false
    Vue.prototype.$echarts = echarts
    
    /* eslint-disable no-new */
    new Vue({
      el: '#app',
      router,
      components: { App },
      template: ''
    })
    
  • echarts使用:
  •  mounted() {
            this.bar = this.$echarts.init(document.getElementById(this.barId))
            this.bar.setOption(this.option)
        },