JavaScript中是否有一个字符来拆分一行代码
1. alert ( "Please Select file
2. \ to delete" );
发布于 2018-01-05 09:58:30
在您的示例中,可以将字符串分成两部分:
alert ( "Please Select file"
+ " to delete");
或者,当它是一个字符串时,就像在您的例子中一样:
alert ( "Please Select file\
to delete");
使用其他代码(而不是引号)时,会忽略换行符,并且完全可以接受。例如:
if(SuperLongConditionWhyIsThisSoLong
&& SuperLongConditionOnAnotherLine
&& SuperLongConditionOnThirdLineSheesh)
{
// launch_missiles();
}
发布于 2018-01-05 11:14:36
将反斜杠放在行尾:
alert("Please Select file\
to delete");
https://stackoverflow.com/questions/-100007114
复制相似问题