Skip to content

字符串排版的小技巧

LYF edited this page May 4, 2016 · 2 revisions

有时候需要写大量的html字符串拼接,以前都是写在一行,现在发现了一种小技巧,可以进行排版

var html = '<div id="lg"> \
               <img hide focus="true" src="//www.baidu.com/img/bd_logo1.png" width="270" height="129"> \
            </div>'

现在ES6中已经有对多行字符串的支持了

var html = `
            <div id="lg"> 
               <img hide focus="true" src="//www.baidu.com/img/bd_logo1.png" width="270" height="129"> \
            </div>
           `
Clone this wiki locally