반응형
Mixins Vuejs에서 기능을 찾을 수 없습니다.
안녕하세요 컴포넌트가 있습니다.
<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>
그리고 나의 믹스인:
export default {
data () {
},
methods: {
fileChanged(file){
if(file){
this.itemImage = file;
this.previewImage = URL.createObjectURL(file);
}
}
}
}
문제는 mixin이 포함되어 있지 않지만 실제로 Import된 것처럼 이 오류를 반환한다는 것입니다.
vue.runtime.esm.js?2b0e:1878 TypeError:이것.fileChanged는 함수가 아닙니다.
다음 제품과의 믹스인 변경도 시도했습니다.
methods: {
fileChanged: function(file){}
}
효과가 없어요.
뭐가 잘못됐지?
다른 개발자용.
나는 해결했다.
문제는 Mixins 파일 확장자가 잘못되었다는 것입니다.
믹스인을 넣었습니다.Mixin.js 대신 vue를 이용해 주셔서 감사합니다.
혼합에서 데이터 블록을 제거하거나 데이터 블록에서 빈 개체를 반환해 보십시오.
믹스인은 다음과 같이 계산해야 합니다.
export default {
data () {},
computed: {
fileChanged(file){
if(file){
this.itemImage = file;
this.previewImage = URL.createObjectURL(file);
}
}
}
}
언급URL : https://stackoverflow.com/questions/54957760/function-in-mixins-vuejs-not-found
반응형
'programing' 카테고리의 다른 글
Java의 경우 super() (0) | 2022.08.13 |
---|---|
main.js가 Vue-cli 웹 팩 템플릿의 Index.html에 링크되는 방법 (0) | 2022.08.13 |
Vue 어플리케이션에서 Vuex를 사용하여 대용량 데이터셋을 효율적으로 처리 (0) | 2022.08.13 |
Vuex 모듈에서 관찰자 유형 대신 개체 값 가져오기 (0) | 2022.08.13 |
오류: "[X][mM][lL]"과(와) 일치하는 처리 명령 대상은 허용되지 않습니다. (0) | 2022.08.13 |