🔥 认识我们的新项目 t0ggles - 您终极的项目管理工具! 🔥

通知 Vue 组件

使用通知组件,您可以显示类似推送(或本地)系统通知的必要消息。

通知组件

以下组件包括在内

  • 通知

通知道具

名称类型默认值描述
颜色对象

包含 Tailwind CSS 颜色类别的对象

colors.bgIos字符串'bg-white dark:bg-[#1e1e1e]'

iOS 主题中的通知背景颜色

colors.bgMaterial字符串'bg-md-light-surface-5 dark:bg-md-dark-surface-5'

Material 主题中的通知背景颜色

colors.deleteIconIos字符串'fill-stone-400 active:fill-stone-200 dark:fill-stone-500 dark:active:fill-stone-700'

iOS 主题中的通知删除图标颜色

colors.deleteIconMd字符串'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant'

Material 主题中的通知删除图标颜色

colors.subtitleIos字符串'text-black dark:text-white'

iOS 主题中的通知副标题颜色

colors.textMaterial字符串'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant'

Material 主题中的通知文本颜色

colors.titleIos字符串'text-black dark:text-white'

iOS 主题中的通知标题颜色

colors.titleRightIos字符串'text-opacity-45 text-black dark:text-white dark:text-opacity-45'

iOS 主题中的通知右侧文本颜色

colors.titleRightMd字符串'text-md-light-on-surface-variant before:bg-md-light-on-surface-variant dark:text-md-dark-on-surface-variant before:dark:bg-md-dark-on-surface-variant'

Material 主题中的通知右侧文本颜色

组件字符串'div'

组件的 HTML 元素

已打开布尔值未定义

允许打开/关闭通知并设置其初始状态

副标题字符串

通知“副标题”区域的内容

文本字符串

通知“文本”区域的内容

标题字符串

通知“标题”区域的内容

titleRightText字符串

通知“标题右侧文本”区域的内容

半透明布尔值true

在 iOS 主题中使通知背景半透明(使用 `backdrop-filter: blur`)

通知事件

名称类型描述
关闭function(e)

单击关闭元素的处理程序

通知插槽

名称描述
按钮

通知按钮内容

图标

通知图标 HTML 布局或图像

副标题

通知“副标题”区域的内容

文本

通知“文本”区域的内容

标题

通知“标题”区域的内容

titlerighttext

通知“标题右侧文本”区域的内容

示例

Notification.vue
<template>
<k-page>
<k-navbar title="Notification" />
<k-notification
:opened="opened.notificationFull"
title="Konsta UI"
title-right-text="now"
subtitle="This is a subtitle"
text="This is a simple notification message"
>
<template #icon>
<demo-icon />
</template>
</k-notification>
<k-notification
:opened="opened.notificationWithButton"
title="Konsta UI"
subtitle="Notification with close button"
text="Click (x) button to close me"
@click="() => (opened.notificationWithButton = false)"
>
<template #icon>
<demo-icon />
</template>
<template #button />
</k-notification>
<k-notification
:opened="opened.notificationCloseOnClick"
title="Konsta UI"
title-right-text="now"
subtitle="Notification with close on click"
text="Click me to close"
@click="() => (opened.notificationCloseOnClick = false)"
>
<template #icon>
<demo-icon />
</template>
</k-notification>
<k-notification
:opened="opened.notificationCallbackOnClose"
title="Konsta UI"
title-right-text="now"
subtitle="Notification with close on click"
text="Click me to close"
@click="
() => {
opened.notificationCallbackOnClose = false;
alertOpened = true;
}
"
>
<template #icon>
<demo-icon />
</template>
</k-notification>
<k-dialog
:opened="alertOpened"
@backdropclick="() => (alertOpened = false)"
>
<template #title>Konsta UI</template>
Notification closed
<template #buttons>
<k-dialog-button @click="() => (alertOpened = false)">
Ok
</k-dialog-button>
</template>
</k-dialog>
<k-block strong-ios outline-ios class="space-y-4">
<p>
Konsta UI comes with simple Notifications component that allows you to
show some useful messages to user and request basic actions.
</p>
<p>
<k-button @click="() => openNotification('notificationFull')">
Full layout notification
</k-button>
</p>
<p>
<k-button @click="() => openNotification('notificationWithButton')">
With Close Button
</k-button>
</p>
<p>
<k-button @click="() => openNotification('notificationCloseOnClick')">
Click to Close
</k-button>
</p>
<p>
<k-button
@click="() => openNotification('notificationCallbackOnClose')"
>
Callback on Close
</k-button>
</p>
</k-block>
</k-page>
</template>
<script>
import { ref, watch } from 'vue';
import {
kPage,
kNavbar,
kNavbarBackLink,
kBlock,
kNotification,
kButton,
kDialog,
kDialogButton,
useTheme,
} from 'konsta/vue';
import DemoIcon from '../components/DemoIcon.vue';
export default {
components: {
kPage,
kNavbar,
kNavbarBackLink,
kBlock,
kNotification,
kButton,
kDialog,
kDialogButton,
DemoIcon,
},
setup() {
const opened = ref({
notificationFull: false,
notificationWithButton: false,
notificationCloseOnClick: false,
notificationCallbackOnClose: false,
});
const alertOpened = ref(false);
const theme = useTheme();
const openNotification = (setter) => {
opened.value = {
notificationFull: false,
notificationWithButton: false,
notificationCloseOnClick: false,
notificationCallbackOnClose: false,
};
opened.value[setter] = true;
};
const autoCloseNotificationFull = () => {
if (opened.value.notificationFull) {
setTimeout(() => {
opened.value.notificationFull = false;
}, 3000);
}
};
watch(() => opened.value.notificationFull, autoCloseNotificationFull);
return {
opened,
alertOpened,
openNotification,
theme,
};
},
};
</script>
代码根据以下许可证授权 MIT.
2022 © Konsta UI 由 nolimits4web.