正常来说已经使用es6 的 模板了如``
//页面层
layer.open({
type: 1,
content:`<div class="child_card">
<div class="mui-card-content ">
<div class="mui-row ">
<div class="mui-col-xs-12 ">
<ul class="mui-table-view ">
<li class="mui-table-view-cell "><i class="icon iconfont"></i> 穿衣 [${this.life.chuanyi[0]}]:<p style="margin: 15px; word-break: break-all;">${this.life.chuanyi[1]}</p></li>
<li class="mui-table-view-cell "> <i class="icon iconfont"></i> 感冒 [${this.life.ganmao[0]}]:<p style="margin: 15px; word-break: break-all;">${this.life.ganmao[1]}</p></li>
<li class="mui-table-view-cell "><i class="icon iconfont"></i> 运动 [${this.life.yundong[0]}]:<p style="margin: 15px; word-break: break-all;">${this.life.yundong[1]}</p></li>
<li class="mui-table-view-cell "><i class="icon iconfont"></i> 空调 [${this.life.kongtiao[0]}]:<p style="margin: 15px; word-break: break-all;">${this.life.kongtiao[1]}</p></li>
<li class="mui-table-view-cell "> <i class="icon iconfont"></i> 紫外线 [${this.life.ziwaixian[0]}]:<p style="margin: 15px; word-break: break-all;">${this.life.ziwaixian[1]}</p></li>
</ul>
</div>
</div>
</div>
</div>`
});
但极少情况下还是使用原始的拼接,以下这种方法会比较舒服
var panelBuffer = '<div class="mui-poppicker">\
<div class="mui-poppicker-header">\
<button class="mui-btn mui-poppicker-btn-cancel">取消</button>\
<button class="mui-btn mui-btn-blue mui-poppicker-btn-ok">确定</button>\
<div class="mui-poppicker-clear"></div>\
</div>\
<div class="mui-poppicker-body">\
</div>\
</div>'; var pickerBuffer = '<div class="mui-picker">\
<div class="mui-picker-inner">\
<div class="mui-pciker-rule mui-pciker-rule-ft"></div>\
<ul class="mui-pciker-list">\
</ul>\
<div class="mui-pciker-rule mui-pciker-rule-bg"></div>\
</div>\
</div>';