JS字符串需要打破原字符串风格,每行处理,这点有点让人受不了。 给个解决方案: 复制代码 代码如下: function aHereDoc() {/* Hello, World! I am a JavaScript here document. Use the "hereDoc" function to extract me. */} function hereDoc(func) { return func.toString().split(/
/).slice(1, -1).join("
"); } console.log(hereDoc(aHereDoc));