如何在模板字面量中使用空格?

huangapple go评论54阅读模式
英文:

How to use spaces in Template Literals?

问题

我有一个<li>元素,使用模板字符串显示动态内容。

<li className='floatLeft'><span><b>Galley Details</b></span><br/>{`${galleyCartsDet[0].quantity} Full Cart ${galleyCartsDet[1].quantity} Half Cart${galleyCartsDet[2].quantity} SMU${galleyCartsDet[3].quantity} Stowage`}</li>

如何在给定的模板字符串中使用空格?

`${galleyCartsDet[0].quantity} Full Cart ${galleyCartsDet[1].quantity} Half Cart${galleyCartsDet[2].quantity} SMU${galleyCartsDet[3].quantity} Stowage`
英文:

I have a &lt;li&gt; element showing dynamic content using Template Literals (template strings).

&lt;li className=&#39;floatLeft&#39;&gt;&lt;span&gt;&lt;b&gt;Galley Details&lt;/b&gt;&lt;/span&gt; &lt;br/&gt;{`${galleyCartsDet[0].quantity} Full Cart ${galleyCartsDet[1].quantity} Half Cart${galleyCartsDet[2].quantity} SMU${galleyCartsDet[3].quantity} Stowage`}&lt;/li&gt;

How can I use spaces in the given template string?

`${galleyCartsDet[0].quantity} Full Cart ${galleyCartsDet[1].quantity} Half Cart${galleyCartsDet[2].quantity} SMU${galleyCartsDet[3].quantity} Stowage`

答案1

得分: 1

You can use spaces in a template string in this way:

\u00A0\u00A0${option.value}\u00A0\u00A0

\u00A0 = 不间断空格
\u0020 = 普通空格

英文:

You can use spaces in a template string in this way:

`\u00A0\u00A0${option.value}\u00A0\u00A0`

\u00A0 = non-breaking space
\u0020 = normal space

huangapple
  • 本文由 发表于 2023年5月18日 03:40:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76275664.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定