0
可能重複:
How to create multiline strings是否有可能在JavaScript中使用@「text」將多行字符串指定爲類似於C#中的變量?
在C#中我可以這樣做:
string str = @"asd
dsa
blah blah blah";
我該怎麼辦JavaScript中的一樣嗎? +每個字符串是糟糕的主意......
可能重複:
How to create multiline strings是否有可能在JavaScript中使用@「text」將多行字符串指定爲類似於C#中的變量?
在C#中我可以這樣做:
string str = @"asd
dsa
blah blah blah";
我該怎麼辦JavaScript中的一樣嗎? +每個字符串是糟糕的主意......
添加\
反斜槓每一行的末尾:
var string = "Hello\
world\
this\
is\
a string!";
HRM,我可以發誓,這是不規範或所有常用瀏覽器的支持。 – ThiefMaster