laravel - laravel-inertia 中的 vue-moment 问题
问题描述
我尝试导入 vue-moment 并使用 .use(VueMoment) 对其进行初始化,如下所示。但是在我这样做之后,整个应用程序都会显示错误。有人面临同样的问题吗?
require('./bootstrap');
// Import modules...
import { createApp, h } from 'vue';
import { App as InertiaApp, plugin as InertiaPlugin } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import VueMoment from 'vue-moment' ////////imported vue-moment
const el = document.getElementById('app');
createApp({
render: () =>
h(InertiaApp, {
initialPage: JSON.parse(el.dataset.page),
resolveComponent: (name) => require(`./Pages/${name}`).default,
}),
})
.mixin({
methods: {
route,
validationError(field){
if(this.$page.props.errors && this.$page.props.errors[field]){
return this.$page.props.errors[field];
}
else{
return null;
}
}
} })
.use(InertiaPlugin)
.use(VueMoment) /////use vue-moment
.mount(el);
InertiaProgress.init({ color: '#4B5563' });
解决方案
第一次安装时刻
npm install moment
<template>
{{today}}
</template>
<script>
import moment from 'moment'
export default {
name:'Home',
data(){
return{
today:moment().startOf('day').toDate(), moment().endOf('day').toDate()
}
}
</script>
推荐阅读
- react-native - 是否有禁用标签栏按钮的选项
- c++ - 在不破坏客户端的情况下修复过载
- python-3.x - 无法使用 Bokeh 和 Python 绘制数据点 - 显示空布局
- html - 屏幕阅读器无法阅读整页
- javascript - 如何控制 v-card 的垂直滚动条?
- selenium - chrome 在 dom 中找不到硒的任何元素
- amazon-web-services - 使用 JupyterNotebook 进行 AWS Congito 身份验证
- pandas - 使用 pandas 运行分析报告时出错,给我一个错误“TypeError: describe_boolean_1d() got an unexpected keyword argument 'title'”
- python - 在父级之外绘制 QGraphicsWidget
- r - Mac上的R Gui应用程序在调用历史记录时添加空行