Node.js 节点JS的新行

Node.js 节点JS的新行,node.js,line-breaks,Node.js,Line Breaks,我一直在试图找出在代码中\r\n放置特征线的位置。下面的代码为我提供了 Enter ID: ID1234Enter Name: John DoeEnter Phone: 12345 我期望的输出是 Enter ID: ID1234 Enter Name: John Doe Enter Phone: 12345 HTML }无需使用forEach来连接unique数组中的字符串。您可以改为使用,它让您指定一个放在中间的“粘合”字符串(在您的示例中,是换行符): <input type=

我一直在试图找出在代码中\r\n放置特征线的位置。下面的代码为我提供了

Enter ID:  ID1234Enter Name: John DoeEnter Phone: 12345
我期望的输出是

Enter ID: ID1234
Enter Name: John Doe
Enter Phone: 12345
HTML


}无需使用
forEach
来连接
unique
数组中的字符串。您可以改为使用,它让您指定一个放在中间的“粘合”字符串(在您的示例中,是换行符):

<input type="text "class="unique" size="9" value="Enter ID: " readonly/>
  <input type="text "class="unique" size="15" value=" " > <br>
  <input type="text "class="unique" size="9" value="Enter Name: " readonly/>
  <input type="text "class="unique" size="15" value="" > <br>
  <input type="text "class="unique" size="9" value="Enter Phone: " readonly/>
  <input type="text "class="unique" size="15" value="" > <br>

  <button id="copybtn" onclick="doCopy()"> Copy to clipboard </button>
function doCopy() {

try{
var unique = document.querySelectorAll('.unique');
var msg ="";

unique.forEach(function (unique) {
msg+=unique.value;

});

var temp =document.createElement("textarea");
var tempMsg = document.createTextNode(msg);
temp.appendChild(tempMsg);

document.body.appendChild(temp);
temp.select();

document.execCommand("copy");
document.body.removeChild(temp);
console.log("Success!")

}
catch(err) {

console.log("There was an error copying");
}
var unique = document.querySelectorAll('.unique');
var msg = unique.join("\r\n");