以下是代码:
const textIn = fs.readFileSync('./txt/input.txt','utf-8');const textOut =‘这是加法:${textIn},\n nCreated on ${Date.now()}';fs.writeFileSync('./txt/output.txt',textOut);
input.txt文件的内容是"hello“。应该发生的是output.txt文件的内容应该是“这是添加: hello 1614606057967。
但上面写着..。
这是添加的:${textIn}在${Date.now()}上创建的
知道为什么吗?
发布于 2021-03-01 14:13:26
根据这些Mozilla医生的说法,你需要把你的字符串放在后面,而不是单引号。
所以你想:
const textOut = `this is the addition: ${textIn}, \nCreated on ${Date.now()}`;https://stackoverflow.com/questions/66423609
复制相似问题