无法使用VUE-C3软件包组件



我想在我的vue JS项目中使用C3图表,所以我下载了此软件包https://github.com/chryb/vue-c3首先,由于示例表明我们需要使用 new Vue((值:handler: new Vue()和VUE返回错误:VUE:未定义。

其次,我不明白为什么示例显示事件类似: this.handler.$emit('init', options)。不应该像 this.$emit('init', options)这样的东西,因为示例返回错误?

有人可以解释如何正确使用此VUE-C3软件包?

这是我的代码:

主组件:

<template>
<div>
  <vue-chart @myEvent="init" :handler="handler"></vue-chart>    
</div>
</template>
<script>
import VueChart from '@/components/VueChart'
export default {
  name: 'HelloWorld',
  data () {
    return {
      handler: {}
    }
  },
  components: { VueChart }
}
</script>

图表组件:

<template>
    <div>
        Content
    </div>
</template>
<script>
export default {
    name: 'VueChart',
    props: ['handler'],
    mounted () {
        const options = {
            data: {
                columns: [
                    ['data1', 2, 4, 5],
                    ['data2', 1, 8, 9]
                ]
            }
        }
        this.$emit('init', options)
    }
}
</script>

显然为时已晚,对OP有用,但无论如何:

import Vue from 'vue'

在您编写new Vue()

的文件中

最新更新