0

我在 6 个 vue 组件中有重复的 onClick 处理程序,我在这个 mixin 中提取了它

//mixin.vue
export default {
  methods: {
  onLastMonth () {
    // get first day of the month.
    // get last day of the month
    // call axios GET method.
  }
}

//component.vue
import mixin1 from './components/mixin.vue'
export default {
  mixins: [mixin1],
  name: 'component1'
}

我想在其他 6 个 vue 组件中重用该 mixin,但 onClick 事件在浏览器控制台中触发了此错误:

属性或方法“onLastMonth”未在实例上定义,但在渲染期间引用。

4

0 回答 0