如何将箭头的html代码放入模板文字中
我想知道如何将HTML箭头放入模板文字中。谢谢。
{sort === "asc" ? `Descending ${\↑}` : `Ascending ${\↓}`}
不起作用。
I am wondering how can I put html arrows in template literals. Thank you.
{sort === "asc" ? `Descending ${\↑}` : `Ascending ${\↓}`}
Doesn't work this way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$ {...}
是您将 javascript表达式插入模板字符串的方式。HTML只是文字。角色参考确实需要以半彩色结束。
根本不需要使用模板字符串(由于您没有嵌入JS表达式),因此您应该只使用常规字符串。
${...}
is how you insert JavaScript expressions into template strings.HTML is just text. Character references do need to end in a semi-colon though.
There's no need to use template strings at all (since you aren't embedding JS expressions in them), you should just use a regular string.