【发布时间】:2017-06-23 10:06:36
【问题描述】:
我正在 Visual Studio Code 中编写自定义组件,并希望将字符串值分配给属性。但是我需要将字符串分成多行。但是每当我这样做时,VSCode 都会给我一个问题列表。
这就是我想要达到的目标:
【问题讨论】:
标签: angularjs string typescript visual-studio-code
我正在 Visual Studio Code 中编写自定义组件,并希望将字符串值分配给属性。但是我需要将字符串分成多行。但是每当我这样做时,VSCode 都会给我一个问题列表。
这就是我想要达到的目标:
【问题讨论】:
标签: angularjs string typescript visual-studio-code
您可以使用+ 连接运算符换行:
template: "<h1>" +
"</h1>"
或者`反引号
template: `<h1>
</h1>`
或\ 反斜杠
template: "<h1>\
</h1>"
【讨论】:
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. They were called "template strings" in prior editions of the ES2015 specification.
您需要使用 backTick 来包含多行字符串文字。 这是 ES6 的一个特性
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals
【讨论】: