示例工程 34-template-slot

34-template-slot/app/README.md

markdown · 0.4 KB

运行:template 与 slot · 原生模板与插槽

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

# 34-template-slot / app

惰性 template、声明式 Shadow DOM 与命名/默认 slot。

## 运行

```bash
cd tutorials/html
python3 -m http.server 8080
# 打开 http://127.0.0.1:8080/examples/34-template-slot/app/
```

## 观察

- template 内容不显示
- 克隆后才进入 DOM
- shadowrootmode 创建声明式 Shadow DOM
- slot name 与 slot 属性对应
- 没有内容时显示回退文字