【发布时间】:2018-08-26 10:06:22
【问题描述】:
我试过把它分成两行:
const templateString = `this is my template
string`
我也试过了:
const templateString = `this is my template\n string`
但这些都不起作用。 templateString 仍然是一行。如何创建多行模板字符串?
【问题讨论】:
-
你的first syntax 应该可以工作。
-
您的意思是在客户端将其呈现为 HTML?那将需要一个
标签。如果您添加
标签,您的第一次尝试是正确的。 -
多行是the expected behaviour,它是需要特殊处理的换行符删除。
-
两种语法都有效。
templateString怎么输出? -
@scraaappy 我在 html 元素中输出它 -
div或p标签
标签: javascript ecmascript-6 template-strings