>我正在使用节点 6.0。这是代码。但是 Node.js 无法识别美元符号("$"(为什么 $ 符号不是红色?
const os = require('os');
const fs = require('fs');
var user = os.userInfo();
fs.appendFile("message.txt","${user.username}")
我想在消息中写下我的用户名.txt
使用 ' 而不是">
fs.appendFile("message.txt", `${ user.username }`)
您正在尝试使用模板文字。
模板文本由反引号 (' '((重音符(字符括起来,而不是双引号或单引号。
所以你应该使用 `${user.username}`
而不是 "${user.username}"
.