2020-07-28 10:03:53 +08:00
|
|
|
---
|
|
|
|
title: Tpl 模板
|
2020-07-29 16:20:21 +08:00
|
|
|
description:
|
2020-07-28 10:03:53 +08:00
|
|
|
type: 0
|
|
|
|
group: ⚙ 组件
|
|
|
|
menuName: Tpl
|
2020-07-29 16:20:21 +08:00
|
|
|
icon:
|
2020-07-28 10:03:53 +08:00
|
|
|
order: 70
|
|
|
|
---
|
2020-07-29 16:20:21 +08:00
|
|
|
|
2021-02-01 20:44:49 +08:00
|
|
|
输出 [模板](../../docs/concepts/template) 的常用组件
|
2020-07-28 10:03:53 +08:00
|
|
|
|
|
|
|
## 基本用法
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
```schema
|
2020-07-28 10:03:53 +08:00
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text": "World!"
|
|
|
|
},
|
|
|
|
"type": "page",
|
|
|
|
"body": {
|
|
|
|
"type": "tpl",
|
|
|
|
"tpl": "Hello ${text}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-02-01 20:44:49 +08:00
|
|
|
更多模板相关配置请看[模板文档](../../docs/concepts/template)
|
2020-07-28 10:03:53 +08:00
|
|
|
|
2021-04-12 19:52:10 +08:00
|
|
|
## 快速编辑
|
|
|
|
|
|
|
|
通过 `quickEdit` 开启快速编辑功能,比如
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
{
|
|
|
|
"type": "form",
|
2021-06-07 10:09:55 +08:00
|
|
|
"body": [
|
2021-04-12 19:52:10 +08:00
|
|
|
{
|
|
|
|
"name": "static",
|
|
|
|
"type": "static",
|
|
|
|
"label": "静态展示",
|
|
|
|
"value": "123",
|
|
|
|
"quickEdit": {
|
|
|
|
"type": "number"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
其他配置项参考 [快速编辑](crud#快速编辑)
|
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
## 属性表
|
|
|
|
|
2022-05-31 20:37:02 +08:00
|
|
|
| 属性名 | 类型 | 默认值 | 说明 |
|
|
|
|
| --------------- | ------------------------------------ | ------- | -------------------------------------------- |
|
|
|
|
| type | `string` | `"tpl"` | 指定为 Tpl 组件 |
|
|
|
|
| className | `string` | | 外层 Dom 的类名 |
|
|
|
|
| tpl | [模板](../../docs/concepts/template) | | 配置模板 |
|
|
|
|
| showNativeTitle | `boolean` | | 是否设置外层 DOM 节点的 title 属性为文本内容 |
|
2022-12-22 21:07:39 +08:00
|
|
|
|
|
|
|
## 事件表
|
|
|
|
|
|
|
|
> 2.5.3 及以上版本
|
|
|
|
|
2023-05-28 22:26:48 +08:00
|
|
|
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细查看[事件动作](../../docs/concepts/event-action)。
|
2022-12-22 21:07:39 +08:00
|
|
|
|
2023-05-28 22:26:48 +08:00
|
|
|
| 事件名称 | 事件参数 | 说明 |
|
|
|
|
| ---------- | -------- | -------------- |
|
|
|
|
| click | - | 点击时触发 |
|
|
|
|
| mouseenter | - | 鼠标移入时触发 |
|
|
|
|
| mouseleave | - | 鼠标移出时触发 |
|
|
|
|
|
|
|
|
### click
|
|
|
|
|
|
|
|
鼠标点击。可以尝试通过`${event.context.nativeEvent}`获取鼠标事件对象。
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
{
|
|
|
|
"type": "tpl",
|
|
|
|
"tpl": "Hello",
|
|
|
|
"onEvent": {
|
|
|
|
"click": {
|
|
|
|
"actions": [
|
|
|
|
{
|
|
|
|
"actionType": "toast",
|
|
|
|
"args": {
|
|
|
|
"msgType": "info",
|
|
|
|
"msg": "${event.context.nativeEvent.type}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### mouseenter
|
|
|
|
|
|
|
|
鼠标移入。可以尝试通过`${event.context.nativeEvent}`获取鼠标事件对象。
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
{
|
|
|
|
"type": "tpl",
|
|
|
|
"tpl": "Hello",
|
|
|
|
"onEvent": {
|
|
|
|
"mouseenter": {
|
|
|
|
"actions": [
|
|
|
|
{
|
|
|
|
"actionType": "toast",
|
|
|
|
"args": {
|
|
|
|
"msgType": "info",
|
|
|
|
"msg": "${event.context.nativeEvent.type}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### mouseleave
|
|
|
|
|
|
|
|
鼠标移出。可以尝试通过`${event.context.nativeEvent}`获取鼠标事件对象。
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
{
|
|
|
|
"type": "tpl",
|
|
|
|
"tpl": "Hello",
|
|
|
|
"onEvent": {
|
|
|
|
"mouseleave": {
|
|
|
|
"actions": [
|
|
|
|
{
|
|
|
|
"actionType": "toast",
|
|
|
|
"args": {
|
|
|
|
"msgType": "info",
|
|
|
|
"msg": "${event.context.nativeEvent.type}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|