problem description
1. The whole project uses the framework of thinkphp. A few days ago, I encountered the following error when I tried to compress html code with gulp-htmlmin:
thinkphp
2.js
:
:
<volist name="list" id="vo"><tr><td>{$vo.Opid}</td><td>{$vo.Storehouse_name}</td><td>{$vo.Product_name}</td><td>{$vo.Quantity}</td><td>{$vo.sn}</td><td>{$vo.assetid}</td><td>{$vo.macaddress}</td><td>{$vo.DoneDate}</td></tr></volist></tbody></table><nav style="text-align:center" id="page"></nav></div><script src="__PUBLIC__/layui_v2/layui.js"></script><script>layui.use(["layer","form","jquery","laypage"], function(){
var layer = layui.layer
,form = layui.form
,laypage = layui.laypage
,$ = layui.$;
$("-sharpsearch-submit").click(function(){
$("-sharpsearch-form").submit();
});
Note: not all js cannot be compressed. For example, the following is successful
.pre-compression code:
<tr>
<td>:</td>
<td>
<select name="rebatecycle">
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
<option value=""></option>
</select>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<div id="market-list"></div>
<script type="text/javascript">
$(".add-submit").live("click",function(){
var need = {cnum:1,brand:2,type:3,project:4,property:5,signingtime:6,yeartime:7,overtime:8};
var empty = true;
var message = "";
$("input").each(function(){
if(need[$(this).attr("name")]){
var value = $(this).val();
if(!value){
empty = false;
var name = $(this).parent().prev().html();
name = name.substring(0,name.length - 1);
message = message + name + "--";
}
}
});
compressed code:
<tr><td>:</td><td><select name="rebatecycle"><option value=""></option><option value=""></option><option value=""></option><option value=""></option><option value=""></option></select></td></tr></table></form></div></div></div><div id="market-list"></div><script type="text/javascript">function getmarketlist(t){var e="<ul style="width:"+$("-sharpmarketname").width()+"px;height: 104px;font-size:12px;overflow: auto;background: -sharpd0f2c5">"; <?php foreach($marketlist as $k => $v) { ?> ;return(""==t||0<="<?php echo $v; ?>".indexOf(t))&&(e+="<li class="market" style="border-bottom:1px solid -sharpf2bebe;list-style: none;margin: 0;padding: 0 14px;height: 25px;line-height: 25px;" value="<?php echo $v; ?>"><?php echo $v; ?></li>"), <?php } ?>
Why is this? I don"t see any difference between the two documents. Is that why js starts with layui.use
? Don"t understand
the htmlmin configuration in the gulp file is as follows:
gulp.task("htmlmin", function() {
var options = {
removeComments: true, //HTML
collapseWhitespace: true, //HTML
minifyJS: true, //JS
minifyCSS: true //CSS
};
return gulp.src("./src/test.html")
//html
.pipe(htmlmin(options))
.pipe(gulp.dest("./Application/Home"));
});
what is the reason? TT
(the timeout of the previous question has been turned off, but the problem is still unsolved)