使用通知组件,您可以显示类似推送(或本地)系统通知的必要消息。
以下组件包括在内
通知
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
颜色 | 对象 | 包含 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 | 通知“标题右侧文本”区域的内容 |
<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 toshow 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>