我想用 javascript ecma6 中的模板文字在字符串中创建字符串。是否可以将双引号或单引号添加到字符串中的模板字面输出中。 我使用路径中的字符串中的目录输出作为字符串遇到了这个问题。
let input = "C:\users\document"
我想要child.stdin.write('athom project --run "C:\users\document"\n')
我来到这个child.stdin.write('athom project --run "' +
${input}+ '"C:\users\document\n')
在 ecma6 中没有更简洁的方法吗?
最佳答案
一个template literal由反引号 (`) 分隔。您当前正在尝试用单引号分隔它。
这样做:
let input = "C:\users\document";
child.stdin.write(`athom project --run "${input}"\n`);
关于javascript - 带有模板文字的字符串中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43834185/