你好,我有一个组件:
<template>
<upload-btn
color="black"
title="Carica foto"
:fileChangedCallback="fileChange" />
</template>
<script>
import fileUploadMixin from './../mixins/fileUploadMixin';
export default {
name: 'compoment',
mixins: [fileUploadMixin],
components:{
'upload-btn': UploadButton
},
data(){..},
methods: {
fileChange(file){
this.fileChanged(file);
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
然后是我的 Mixin:
export default {
data () {
},
methods: {
fileChanged(file){
if(file){
this.itemImage = file;
this.previewImage = URL.createObjectURL(file);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是它返回这个错误,就像不包含mixins,但实际上是导入的。
vue.runtime.esm.js?2b0e:1878 TypeError: this.fileChanged 不是函数
我也试过用以下方法改变我的 mixin:
methods: {
fileChanged: function(file){}
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
我怎么了?