<tap-toast>
轻量级提示组件。提供不同语义类型(info、success、warning、error、loading)、自定义操作按钮以及命令式静态方法调用。
Example
Loading...
<tap-button .color=${"positive"} @click=${()=>customElements.get('tap-toast').open('success', '这是一条消息')}>
Success
</tap-button>
<tap-button .color=${"notice"} @click=${()=>customElements.get('tap-toast').open('warning', '这是一条消息')}>
Warning
</tap-button>
<tap-button .color=${"negative"} @click=${()=>customElements.get('tap-toast').open('error', '这是一条消息')}>
Error
</tap-button>
命令式调用
import { Toast } from '@mantou/tap-ui/elements/toast';
Toast.open('success', '这是一条消息');
Toast.open({
type: 'info',
content: '支持操作按钮',
action: {
text: '撤销',
handle: () => console.log('undo'),
},
});
const close = Toast.open({ type: 'loading', content: '加载中…', duration: Infinity });
close();
API
Shadow DOM; Extends GemElement
Static Properties
| Property |
Type |
instance |
TapToastElement | undefined |
Static Methods
| Method |
Type |
open |
{ (options: ToastOptions): () => void; (type: Type, content: string | TemplateResult): () => void; } |
Instance Properties
| Property(Attribute) |
Reactive |
Type |
items |
Yes |
ToastItem[] |
Other
| Type |
Value |
| Part |
item, icon, body, action |