ruoyi-plus-soybean/src/views/home/index.vue

50 lines
1.2 KiB
Vue
Raw Normal View History

2021-08-17 14:59:59 +08:00
<template>
2021-08-18 12:02:59 +08:00
<div>
<n-space>
<n-button v-for="item in actions" :key="item.key" type="primary" @click="handleClick(item.key)">
{{ item.label }}
</n-button>
</n-space>
</div>
2021-08-17 14:59:59 +08:00
</template>
2021-08-18 12:02:59 +08:00
<script lang="ts" setup>
import { useLoadingBar, useDialog, useNotification, useMessage } from 'naive-ui';
type ActionType = 'loading-bar' | 'dialog' | 'notification' | 'message';
interface Action {
key: ActionType;
label: string;
}
const loadingBar = useLoadingBar();
const dialog = useDialog();
const notification = useNotification();
const message = useMessage();
const actions: Action[] = [
{ key: 'loading-bar', label: 'loading bar' },
{ key: 'dialog', label: 'dialog' },
{ key: 'notification', label: 'notification' },
{ key: 'message', label: 'message' }
];
function handleClick(type: ActionType) {
if (type === 'loading-bar') {
loadingBar.start();
setTimeout(() => {
loadingBar.finish();
}, 5000);
}
if (type === 'dialog') {
dialog.info({ content: '弹窗示例!' });
}
if (type === 'notification') {
notification.info({ content: '通知示例!' });
}
if (type === 'message') {
message.info('消息示例!');
}
}
</script>
2021-08-17 14:59:59 +08:00
<style scoped></style>