ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 模板配置JSON 放在模板的根目录下,用于用户自定义一些配置、前台调取。 支持text、textarea、radio、checkbox、select、image、images、date、datetime控件 组件可前往这里了解:[字段类型与组件](%E5%89%8D%E8%A8%80.md) ## 使用说明 ### 一级写法 说明 ![](https://img.kancloud.cn/87/a0/87a00a8abf20e7d2802626228b2e25eb_349x259.png) | key | 更改key值 | value值 | 是否必填| 说明 | | --- | --- | --- | --- | --- | | field | <span style="color:red;">可更改</span> | - | - | <span style="color:red;">field改为king</span><br>前台调用方式<br>{$Tpl.<span style="color:red;">king</span>} | | title | 否 | 随便填 | 否 | - | | type | 否 | text<br>textarea<br>radio<br>checkbox<br>select<br>image<br>images<br>date<br>datetime | --- | 具体说明<br>[字段类型与组件](%E5%89%8D%E8%A8%80.md) | | tips | 否 | 随便填 | 否 | 后台模板配置时候提示效果 | | rules| 否 | - | 否 | 验证规则<br>如果多个验证请用 <span style="color:red;">;</span> 隔开<br>[查看规则](%E9%AA%8C%E8%AF%81%E8%A7%84%E5%88%99.md) | | error_tips | 否 | 随便填 | 否 | 自定义验证规则错误信息。<br>填写了,会覆盖规则的错误提示消息。 | | value | 否 | - | 否 | 默认值 | ### 多级写法 说明 ![](https://img.kancloud.cn/1b/f8/1bf8887abd75f74721ff8526d07431c8_409x504.png) | key | 更改key值 | value值 | 是否必填| 说明 | | --- | --- | --- | --- | --- | | base/more | <span style="color:red;">可更改</span> | - | - | <span style="color:red;">base改为king</span><br>前台调用方式<br>{$Tpl.<span style="color:red;">king</span>.item中的key值} | | title | 否 | 随便填 | 否 | - | | item | 否 | - | 是 | 多个一级写法组成<br>key值不能重复 | ## 使用示例 ### 简单写法(一级) 前台调用方式,如下配置文件。调取标题字段的值。 **{$Tpl.field}** 或者 **{$Tpl['field']}** ~~~ { "field": { "title": "标题", "type": "text", "tips": "提示", "rules": "required;length(3~16)", "error_tips": "值必须", "value": "" } } ~~~ 效果图 ![](https://img.kancloud.cn/c8/7c/c87c00878c38732294a020a9cd8a533b_803x252.jpg) ### 配置分组写法 (多级) 调取标题 **{$Tpl.base.text}** 或者 **{$Tpl['base']['text']}** 示例代码 ~~~ { "base": { "title": "基础配置", "item": { "text": { "title": "标题", "type": "text", "tips": "提示", "rules": "required;length(3~16)", "error_tips": "值必须", "value": "" }, "textarea": { "title": "描述", "type": "textarea", "tips": "", "rules": "", "error_tips": "", "value": "" }, "radio": { "title": "是否显示", "type": "radio", "tips": "", "rules": "", "error_tips": "", "options": { "1": "显示", "0": "不显示" }, "value": "1" }, "checkbox": { "title": "多项选择", "type": "checkbox", "tips": "", "rules": "", "error_tips": "", "options": { "1": "显示1", "2": "显示3", "0": "不显示" }, "value": "1,2" }, "select": { "title": "下拉选择", "type": "select", "tips": "我是提示", "rules": "", "error_tips": "", "options": { "1": "测试1", "2": "测试2", "3": "测试3" }, "value": "2" }, "selects": { "title": "下拉多项选择", "type": "selects", "tips": "我是提示", "rules": "", "error_tips": "", "options": { "1": "测试1", "2": "测试2", "3": "测试3" }, "value": "2,3" } } }, "more": { "title": "更多选项", "item": { "image": { "title": "图片", "type": "image", "tips": "请上传图片", "rules": "required", "error_tips": "请上传图片", "value": "" }, "images": { "title": "图片", "type": "images", "tips": "请上传图片", "rules": "required", "error_tips": "请上传图片", "max_number": 5, "value": "" }, "date": { "title": "日期", "type": "date", "tips": "", "rules": "required", "error_tips": "日期选择", "value": "" }, "datetime": { "title": "日期时间", "type": "datetime", "tips": "日期时间", "rules": "", "error_tips": "日期时间", "value": "" } } } } ~~~ 分组后的效果图 ![](https://img.kancloud.cn/81/74/8174709ca8e948bef7965c2261411f93_1193x825.png)