如何在vue js中使用c3?

问题描述 投票:-1回答:1

我一直在尝试从c3网站,但它不起作用,这是我的代码

在模板中

<vue-c3 :handler="handler"></vue-c3>

然后在脚本中

<script>
import VueC3 from 'vue-c3'

export default {
  name: 'Dashboard',
  props: ['handler'],
  components:{ VueC3 },
  data() { 
    return {

    }
  },
  methods: {
    initChart(){
      const options = {
        data: {
          columns: [
            ['data1', 2, 4, 1, 5, 2, 1],
            ['data2', 7, 2, 4, 6, 10, 1]
          ],
        },
      }
      this.handler.$emit('init', options)
    }
  },
  mounted() {
    this.initChart();
  }
};
</script>

图表没有呈现,有什么问题?

vue.js c3.js
1个回答
0
投票

你错过了

data () {
  return {
    handler: new Vue()
  }
}

来自文档https://github.com/chryb/vue-c3

© www.soinside.com 2019 - 2024. All rights reserved.