我在changeFormatDate.js文件中编写了一些日期处理实用程序,用于格式化日期时间,
'changeFormatDate.js'
const showDate = function (d) {
return moment(d).format("DD/MM/YYYY");
}
我尝试在 HTML 模板中呈现这个函数。
'template.vue'
<template lang="pug">
.data(v-for="(rata,index) in loan.schedule")
.values
span {{index+1}}
span {{showDate(rata.date)}}
</template>
<script>
import { showDate } from "@/util/changeFormatDate.js";
import moment from "moment";
export default {
name: "TimetableApplication",
props: {
loan: { type: Object, required: true }
},
methods: {
showDate
}
};
</script>
但我仍然有一个错误“方法“showDate”在组件定义中具有类型“未定义”。您是否正确引用了该函数?”如何正确定义在 HTML 模板中使用它?
最佳答案
您似乎错过了“changeFormatDate.js”中的导出
关于javascript - 方法 "showDate"在组件定义中具有类型 "undefined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60449670/