在 es6 模板文字中,如何将长模板文字包装为多行而不在字符串中创建新行?
例如,如果您这样做:
const text = `a very long string that just continues
and continues and continues`
然后它将为字符串创建一个新行符号,将其解释为有一个新行。如何将长模板文字包装为多行而不创建换行符?
如果你介绍一个行延续 (\
) 在文字中的换行符处,它不会在输出中创建换行符:
const text = `a very long string that just continues\
and continues and continues`;
console.log(text); // a very long string that just continuesand continues and continues
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)