javascript - 方法“showDate”在组件定义中具有“未定义”类型
问题描述
我在 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”中的导出
推荐阅读
- google-cloud-platform - GCP - 无法打印身份令牌
- azure - Azure AD B2C 注销不会使令牌无效
- java - 如何修复应用程序构造函数中的异常
- minikube - 实现路由转发方法的问题
- pandas - 添加到数据框时电子邮件正文被切断
- jquery - 多用户同时提问的问答式聊天界面
- c - 如何使用 Clang 和 MinGW C/C++ 库编译代码?(float.h 的特殊问题)
- xodus - 两个不同商店的嵌套游标
- continuous-integration - 从releases/*合并到master时如何触发job?
- swift - 如何获得具有完成和结果类型工作的泛型?