Popup 是一个弹出窗口,其中包含任何 HTML 内容,该内容会弹出到应用程序的主要内容之上。 Popup 与所有其他覆盖层一样,是所谓的“临时视图”的一部分。
包含以下组件
Popup
- 弹出元素名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
backdrop | 布尔值 | true | 启用 Popup 背景(弹出窗口后面的半透明暗层) |
colors | 对象 | 包含 Tailwind CSS 颜色类别的对象 | |
colors.bg | 字符串 | 'bg-white dark:bg-black' | Popup 背景颜色 |
opened | 布尔值 | false | 允许打开/关闭 Popup 并设置其初始状态 |
size | 字符串 | 'w-screen h-screen md:w-160 md:h-160' | Tailwind CSS 尺寸类 |
onBackdropClick | function(e) | 点击背景元素的处理程序 |
<script>import {Page,Navbar,NavbarBackLink,Popup,Block,Link,Button,} from 'konsta/svelte';let popupOpened = false;</script><Page><Navbar title="Popup" /><Block strong class="space-y-4"><p>Popup is a modal window with any HTML content that pops up over App's maincontent. Popup as all other overlays is part of so called "TemporaryViews".</p><p><Button onClick={() => (popupOpened = true)}>Open Popup</Button></p></Block><Popup opened={popupOpened} onBackdropClick={() => (popupOpened = false)}><Page><Navbar title="Popup"><Link slot="right" navbar onClick={() => (popupOpened = false)}>Close</Link></Navbar><Block class="space-y-4"><p>Here comes popup. You can put here anything, even independent viewwith its own navigation. Also not, that by default popup looks a bitdifferent on iPhone/iPod and iPad, on iPhone it is fullscreen.</p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendissefaucibus mauris leo, eu bibendum neque congue non. Ut leo mauris,eleifend eu commodo a, egestas ac urna. Maecenas in lacus faucibus,viverra ipsum pulvinar, molestie arcu. Etiam lacinia venenatisdignissim. Suspendisse non nisl semper tellus malesuada suscipit eu eteros. Nulla eu enim quis quam elementum vulputate. Mauris ornareconsequat nunc viverra pellentesque. Aenean semper eu massa sit ametaliquam. Integer et neque sed libero mollis elementum at vitae ligula.Vestibulum pharetra sed libero sed porttitor. Suspendisse a faucibuslectus.</p><p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula.Phasellus blandit nisl ut lorem semper pharetra. Nullam tortor nibh,suscipit in consequat vel, feugiat sed quam. Nam risus libero, auctorvel tristique ac, malesuada ut ante. Sed molestie, est in eleifendsagittis, leo tortor ullamcorper erat, at vulputate eros sapien neclibero. Mauris dapibus laoreet nibh quis bibendum. Fusce dolor sem,suscipit in iaculis id, pharetra at urna. Pellentesque tempor conguemassa quis faucibus. Vestibulum nunc eros, convallis blandit dui sitamet, gravida adipiscing libero.</p></Block></Page></Popup></Page>