pearadmin layui laytpl 模板数据绑定方法 跟layui官网的有点区别
实例:
<script type="text/html" id="showInfo"> <h2>{{ "{{d.title}}" }}</h2> </script> <script> layui.use(['jquery', 'laytpl'], function () { var laytpl = layui.laytpl; let $ = layui.jquery var json = { title: "我是标题", content: "我是内容" } var showTpl = showInfo.innerHTML; //获取模板,即上面所定义的 <script id="showInfo"> var showTplDiv = document.getElementById('showTplDiv'); //视图 即上面的 <div id="showTplDiv"> laytpl(showTpl).render(json, function (html) { //渲染视图 showTplDiv.innerHTML = html; }); }); </script>