Javascript 如何在Vue中的不同文件中使用函数
我是vue的新手,我正在尝试使用一个助手函数,arrayDateFormatter在我导入的一个.vue文件中。我试图在Javascript 如何在Vue中的不同文件中使用函数,javascript,vue.js,Javascript,Vue.js,我是vue的新手,我正在尝试使用一个助手函数,arrayDateFormatter在我导入的一个.vue文件中。我试图在mounted()中使用它,但它从未被调用,之后什么也没有我在控制台中没有收到任何错误 我的vue文件 <template> ..... </template> <script> import archives from "@/4.objects/o-archives"; import fullBanner from "@/4.object
mounted()
中使用它,但它从未被调用,之后什么也没有我在控制台中没有收到任何错误
我的vue文件
<template>
.....
</template>
<script>
import archives from "@/4.objects/o-archives";
import fullBanner from "@/4.objects/o-full-banner";
import speakerInfo from "@/4.objects/o-speaker-info";
import newsletter from "@/4.objects/o-newsletter";
import dataLoaderMixin from "@/mixins/dataLoader-mixin";
import arrayDateFormatter from "../mixins/gloabalEventsDateFormate-mixin";
export default {
components: {
....
},
mixins: [dataLoaderMixin],
data() {
return {
speakers: [],
talkInfo: null,
archives: []
};
},
async mounted() {
try {
const response = await this.fetchEventsByProject();
console.log(response.data.data.listOnlineEvents.items);
//nothing gets triggered after here
const currentEvent = arrayDateFormatter(response);
console.log('current event');
console.log(currentEvent);
this.archives = this.fetchData("archive");
} catch (err) {
return err
}
}
};
</script>
看来我必须这样导入文件
import {arrayDateFormatter} from "../mixins/gloabalEventsDateFormate-mixin";
import {arrayDateFormatter} from "../mixins/gloabalEventsDateFormate-mixin";