【发布时间】:2022-08-01 12:21:37
【问题描述】:
我想尝试使用template literals,但它不起作用:它显示的是文字变量名称,而不是值。我正在使用 Chrome v50.0.2(和 jQuery)。
例子
console.log(\'categoryName: ${this.categoryName}\\ncategoryElements: ${this.categoryElements} \');
输出
${this.categoryName}
categoryElements: ${this.categoryElements}
-
使用重音 ` 而不是单引号
\'或双引号\"。
标签: javascript template-literals