Appearance
h
简易 DOM 创建函数,类似 hyperscript 的轻量实现。
用法
ts
import { h } from '@qingpai/utils'
const el = h('span', { 'class': 'qp-badge', 'data-id': 1 }, [
'文本',
h('i', { class: 'qp-icon' }),
])参数
| 名称 | 类型 | 描述 |
|---|---|---|
tag | string | 标签名 |
attrs? | Record<string, any> | 属性对象,经 setAttribute 写入(null / undefined 跳过) |
children? | Node | string | null | undefined 或其数组 | 子节点;字符串中的 HTML 实体(如 )会解析为文档片段 |
返回值
HTMLElement — 创建好的元素。