feat: v-loading support for element plus (#5008)

This commit is contained in:
Netfan 2024-12-04 21:42:48 +08:00 committed by GitHub
parent e23486dbc6
commit fccbe44cf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 56 additions and 44 deletions

View File

@ -7,6 +7,7 @@ import '@vben/styles';
import '@vben/styles/ele'; import '@vben/styles/ele';
import { useTitle } from '@vueuse/core'; import { useTitle } from '@vueuse/core';
import { ElLoading } from 'element-plus';
import { $t, setupI18n } from '#/locales'; import { $t, setupI18n } from '#/locales';
@ -19,6 +20,9 @@ async function bootstrap(namespace: string) {
await initComponentAdapter(); await initComponentAdapter();
const app = createApp(App); const app = createApp(App);
// 注册Element Plus提供的v-loading指令
app.directive('loading', ElLoading.directive);
// 国际化 i18n 配置 // 国际化 i18n 配置
await setupI18n(app); await setupI18n(app);

View File

@ -61,7 +61,8 @@ const segmentedOptions = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
description="支持多语言,主题功能集成切换等" description="支持多语言,主题功能集成切换等"
title="Element Plus组件使用演示" title="Element Plus组件使用演示"
> >
<ElCard class="mb-5"> <div class="flex flex-wrap gap-5">
<ElCard class="mb-5 w-auto">
<template #header> 按钮 </template> <template #header> 按钮 </template>
<ElSpace> <ElSpace>
<ElButton text>Text</ElButton> <ElButton text>Text</ElButton>
@ -73,7 +74,7 @@ const segmentedOptions = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
<ElButton type="danger"> Error </ElButton> <ElButton type="danger"> Error </ElButton>
</ElSpace> </ElSpace>
</ElCard> </ElCard>
<ElCard class="mb-5"> <ElCard class="mb-5 w-80">
<template #header> Message </template> <template #header> Message </template>
<ElSpace> <ElSpace>
<ElButton type="info" @click="info"> 信息 </ElButton> <ElButton type="info" @click="info"> 信息 </ElButton>
@ -82,7 +83,7 @@ const segmentedOptions = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
<ElButton type="success" @click="success"> 成功 </ElButton> <ElButton type="success" @click="success"> 成功 </ElButton>
</ElSpace> </ElSpace>
</ElCard> </ElCard>
<ElCard class="mb-5"> <ElCard class="mb-5 w-80">
<template #header> Notification </template> <template #header> Notification </template>
<ElSpace> <ElSpace>
<ElButton type="info" @click="notify('info')"> 信息 </ElButton> <ElButton type="info" @click="notify('info')"> 信息 </ElButton>
@ -91,7 +92,7 @@ const segmentedOptions = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
<ElButton type="success" @click="notify('success')"> 成功 </ElButton> <ElButton type="success" @click="notify('success')"> 成功 </ElButton>
</ElSpace> </ElSpace>
</ElCard> </ElCard>
<ElCard class="mb-5"> <ElCard class="mb-5 w-auto">
<template #header> Segmented </template> <template #header> Segmented </template>
<ElSegmented <ElSegmented
v-model="segmentedValue" v-model="segmentedValue"
@ -99,11 +100,18 @@ const segmentedOptions = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
size="large" size="large"
/> />
</ElCard> </ElCard>
<ElCard class="mb-5"> <ElCard class="mb-5 w-80">
<template #header> V-Loading </template>
<div class="flex size-72 items-center justify-center" v-loading="true">
一些演示的内容
</div>
</ElCard>
<ElCard class="mb-5 w-80">
<ElTable :data="tableData" stripe> <ElTable :data="tableData" stripe>
<ElTable.TableColumn label="测试列1" prop="prop1" /> <ElTable.TableColumn label="测试列1" prop="prop1" />
<ElTable.TableColumn label="测试列2" prop="prop2" /> <ElTable.TableColumn label="测试列2" prop="prop2" />
</ElTable> </ElTable>
</ElCard> </ElCard>
</div>
</Page> </Page>
</template> </template>