当我尝试将道具传递给 mixin 时,我得到一个Cannot read property of undefined error
.
我是不是做错了什么,或者我还能如何克服这个问题?
mixins/BarMixin.js
:
export default baz => {
return {
// my mixin code...
}
}
components/FooComponent.vue
:
<script>
import BarMixin from '@/mixins/BarMixin.js'
export default {
mixins: [BarMixin(this.baz)],
props: {
bar: {
type: Boolean,
required: true,
},
},
}
</script>
然后我尝试使用它,如下所示:
pages/foo.vue
<template>
<FooComponent :baz="true" />
</template>
<script>
import FooComponent from '@/components/FooComponent.vue'
export default {
components: {
FooComponent,
},
}
</script>