add dayjs plugin
This commit is contained in:
1 parent
57b44f1d28
commit
74f62354a2
7 files changed
+49
-2
No files matched your search
+11
-1
@@ -6,5 +6,15 @@ import ElementPlus from 'element-plus';
|
||||
import i18n from './i18n/index';
|
||||
import './assets/css/tailwind.css';
|
||||
import './assets/scss/style.scss';
|
||||
import dayjs from './plugins/dayjs';
|
||||
|
||||
createApp(App).use(router).use(store).use(ElementPlus).use(i18n).mount('#app');
|
||||
const app = createApp(App);
|
||||
|
||||
app.use(router);
|
||||
app.use(store);
|
||||
app.use(ElementPlus);
|
||||
app.use(i18n);
|
||||
app.use(dayjs, {
|
||||
formatString: 'YYYY-MM-DD HH:mm:ss'
|
||||
});
|
||||
app.mount('#app');
|
||||
@@ -11,7 +11,11 @@
|
||||
>
|
||||
<el-table :data="items" v-loading="loading">
|
||||
<el-table-column prop="title" :label="$t('common.entity.title')"> </el-table-column>
|
||||
<el-table-column prop="updated_at" :label="$t('common.entity.updatedAt')"> </el-table-column>
|
||||
<el-table-column prop="updated_at" :label="$t('common.entity.updatedAt')">
|
||||
<template #default="scope">
|
||||
{{ $dayjs.format(scope.row.updated_at) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('common.entity.operation')">
|
||||
<template #default="scope">
|
||||
<el-button @click="onEdit(scope.row)" round type="primary" size="mini">
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { App } from 'vue';
|
||||
|
||||
export interface IDayJS {
|
||||
format: (v: string, formatString?: string) => string;
|
||||
}
|
||||
|
||||
interface IOptions {
|
||||
formatString: string;
|
||||
}
|
||||
|
||||
export default {
|
||||
install: (app: App, options: IOptions) => {
|
||||
app.config.globalProperties.$dayjs = {
|
||||
format(v: string, formatString: string = '') {
|
||||
return dayjs(v).format(formatString || options.formatString);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
declare module '@vue/runtime-core' {
|
||||
interface ComponentCustomProperties {
|
||||
$dayjs: IDayJS;
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export const DEFAULT_LIMIT = 10;
|
||||
export const DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss';
|
||||
Reference in new issue
Block a user