找不到 Mixins Vuejs 中的函数

Lor*_*rti 4 mixins vuejs2

你好,我有一个组件:

<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)

但它不起作用。

我怎么了?

Lor*_*rti 6

对于其他开发人员。

我已经解决了。

问题是我的 Mixins 文件扩展名是错误的。

我已经把Mixin.vue而不是Mixin.js,谢谢大家的回答。