简体   繁体   中英

How to use mixins in Vue 3

I've been following this link https://www.telerik.com/blogs/real-time-data-visualization-using-vue-and-socket.io to create a real time line chart using vue.js and socket.io

My LineChart.js:

import { Line, mixins } from 'vue-chartjs'
const { reactiveProp } = mixins
    
export default {
  extends: Line,
  mixins: [reactiveProp],
  props: ['options'],
  mounted () {
    this.renderChart(this.chartData, this.options)
  }
}

The error I got:

Uncaught TypeError: vue_chartjs__WEBPACK_IMPORTED_MODULE_0__.mixins is undefined

and the webpage I got is completely blank. When I delete the mixins from my LineChart.js, the error I get becomes Uncaught TypeError: undefined has no properties instead.

So, I heard that it is because Vue3 does not support mixins but the tutorial is in Vue 2, how can I replace the mixins?

It's not the Vue 3, From vue-chartjs V4 version, Mixins have been removed .

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM