html代码复用问题
在html代码中,若某些html代码需要多处引用,可以先创建一个js文件,以如下方式进行编辑
//list文件夹里的公共html代码块,可直接通过引用<script src="../../script/list.js"></script>来填充相应代码片段
document.writeln(" <script type=\'text/x-dot-template\' id=\'dot_interpolation\'>");
document.writeln(" {{##def.togeter1:");
document.writeln(" <div><img src={{=itz.goods_photo}} alt=\'消息\' onclick=\'openwin2(\"goods_xiangqing\",{{=itz.goods_id}});\'>");
document.writeln(" <div class=\'p_t\'>{{=itz.goods_name}}</div>");
document.writeln(" <div style=\'float:left\'>");
document.writeln(" <h5 style=\'color:#ff4500;margin-top:12px\'>¥{{=itz.goods_coastPrice}}</h5>");
document.writeln(" <s style=\'color:rgba(0,0,0,.3);font-size:13px\'>¥{{=itz.goods_rullPrice}}</s>");
document.writeln(" </div>");
document.writeln(" <div class=\'qiang\'>立即抢</div>");
document.writeln(" </div>");
document.writeln(" <div class=\'good_id\'>{{=itz.goods_id}}</div>");
document.writeln(" #}} {{ for(var i=0;i");
document.writeln(" <it.length;i++){ }} {{ var itz=it[i]; }}");
document.writeln(" {{#def.togeter1}} {{ } }}");
document.writeln(" </script>");
在具体引用中,通过在body标签里引用<script src="../../script/list.js"></script>即可进行代码复用,此方法会产生较多冗余操作,不推荐使用

浙公网安备 33010602011771号