在nodeJs v4.4.2中使用ES6模板文字 [英] Using ES6 Template Literals in nodeJs v4.4.2
本文介绍了在nodeJs v4.4.2中使用ES6模板文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在Node v4.4.2.中使用ES6模板文字.
I need to use ES6 Template Literals in Node v4.4.2.
设置jsconfig.json
后,我无法正确创建我的字符串.
After setting jsconfig.json
I am not able to create my string properly.
知道我在这里想念什么吗?
Any idea what am I missing here?
var name = "Juan",
job = "flying penguin";
var sentence = 'Hello${name},the ${job}!';
console.log(sentence);
------------- jsconfig.json
------------- jsconfig.json
{
"compilerOptions": {
"target": "ES6"
}
}
推荐答案
2件事情:
- `代替'
-
$
后没有空格
- ` instead of '
- No spaces after
$
类似这样的东西:
var name = "Juan",
job = "flying penguin";
var sentence = `Hello ${name},the ${job}!`;
console.log(sentence);
这篇关于在nodeJs v4.4.2中使用ES6模板文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文