🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
{include}用于载入其他模板到当前模板中。 在包含模板中可用的变量,载入后在当前模板仍然可用。 <table border="1"> <colgroup> <col align="center"> <col align="center"> <col align="center"> <col align="center"> <col> </colgroup> <thead><tr> <th align="center">参数名称</th> <th align="center">类型</th> <th align="center">必选参数</th> <th align="center">默认值</th> <th>说明</th> </tr></thead> <tbody> <tr> <td align="center">file</td> <td align="center">string</td> <td align="center">Yes</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>包含载入的文件名</td> </tr> <tr> <td align="center">assign</td> <td align="center">string</td> <td align="center">No</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>将包含的文件内容赋值给变量</td> </tr> <tr> <td align="center">cache_lifetime</td> <td align="center">integer</td> <td align="center">No</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>单独开启被包含模板的缓存时间</td> </tr> <tr> <td align="center">compile_id</td> <td align="center">string/integer</td> <td align="center">No</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>单独设置被包含模板的编译ID</td> </tr> <tr> <td align="center">cache_id</td> <td align="center">string/integer</td> <td align="center">No</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>单独设置被包含模板的缓存ID</td> </tr> <tr> <td align="center">scope</td> <td align="center">string</td> <td align="center">No</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>定义被包含模板的赋值变量作用范围: 'parent','root' 或 'global'</td> </tr> <tr> <td align="center">[var ...]</td> <td align="center">[var type]</td> <td align="center">No</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>传递到包含模板的变量</td> </tr> </tbody> </table> 可选标记: <table border="1"> <colgroup> <col align="center"> <col> </colgroup> <thead><tr> <th align="center">名称</th> <th>说明</th> </tr></thead> <tbody> <tr> <td align="center">nocache</td> <td>关闭包含模板的缓存</td> </tr> <tr> <td align="center">caching</td> <td>打开包含模板的缓存</td> </tr> <tr> <td align="center">inline</td> <td>设置成true时,在编译时把包含模板的内容也合并到当前模板的编译文件中。</td> </tr> </tbody> </table> 简单 {include} 例子 ``` <html> <head> <title>_{$title}_</title> </head> <body> _{include file='Common/head.html'}_ hello world! _{include 'Common/footer.html'}_ </body> </html> ```