我用casperjs做了一個測試網頁加載速度的demo,然后想通過fs.write把結果打印在一張txt上,我加入了換行符'n'但是打印出來的東西依舊不會換行,代碼其中的一段類似這樣:var timeouttxt = '';function timeOutTxt() { if (timend > 800) { timeouttxt = 'Page Times is ' + timend + ' is timeout 800\n'; } else { timeouttxt = 'Page Times is ' + timend + '\n'; }}txtData += 'the links length: ' + links.length + '\n' + 'Page url is ' + this.getCurrentUrl() + '\n' + 'Page title is ' + this.getTitle() + ' index: ' + index + '\n' + timeouttxt + '-----------------------------------------------------\n';fs.write(file, txtData, function(err) { if (err) return err;});輸入出來的txt類似這樣:請教是什么原因?怎樣換行?謝謝
nodejs寫入的文件無法換行
慕尼黑的夜晚無繁華
2018-10-10 17:15:17