【问题标题】:Template String and Interpolation String in Javascript ES6 don't WorkingJavascript ES6 中的模板字符串和插值字符串不起作用
【发布时间】:2020-02-29 02:28:59
【问题描述】:

它看起来很简单,但它在我的 Chrome 浏览器中不起作用。有人可以帮我吗?

这是我的代码:

var a = "Something";
Var b = "is";
console.log('${a} ${b} wrong.');

我确实将这段代码放在了 chrome 浏览器的控制台中,但它不工作应该如何工作。

【问题讨论】:

  • 你需要反引号,(``),而不是引号。

标签: javascript string concatenation frontend


【解决方案1】:

你需要使用反引号。

let a = "Something";
let b = "is";
console.log(`${a} ${b} wrong.`);

【讨论】:

    猜你喜欢
    • 2016-09-19
    • 2022-11-04
    • 1970-01-01
    • 1970-01-01
    • 2015-10-23
    • 1970-01-01
    • 1970-01-01
    • 2015-02-18
    相关资源
    最近更新 更多