在php、python中都有heredoc方式的字符串定义方法:
php:
$sql=<<<EOD select * from pages where pagename='$pn' EOD;
print """ This is an example of a string in the heredoc syntax. This text can span multiple lines """
拼接方式一:
var str = "\ Here is line one \ And line two \ Finally, line three! \ ";alert(str);
var __template = '<tr>'+ '<td>#salarySN#</td>'+ '<td>#name#</td>'+ '<td>#TDR_NAME#</td>'+ '<td>#TSD_NAME#</td>'+ '<td>#WORK_STATUS#</td>'+ '<td>#isleader_display#</td>'+ '<td>' +'<a href="javascript:void(-1)">设置角色</a>' +'</td></tr>';
给个解决方案:
function aHereDoc() {/* Hello, World! I am a JavaScript here document. Use the 'hereDoc' function to extract me. */}function hereDoc(func) { return func.toString().split(/\n/).slice(1, -1).join('\n'); } console.log(hereDoc(aHereDoc));