[英]What is the difference between {} and ${} in JSX?
The ${}
is template literals. ${}
是模板文字。 What's {}
without the $
sign?没有$
符号的{}
是什么?
In React:在反应:
function App(){
return(<div temp={3}></div>);
}
(I was looking up the difference and nothing came up. So, I think this question is needed as I couldn't know if I was using JS or JSX.) (我正在查找差异,但没有发现任何问题。所以,我认为这个问题是有必要的,因为我不知道我使用的是 JS 还是 JSX。)
You're quite correct that javascript uses ${}
to make use of template literals within strings surrounded by backticks `您非常正确,javascript 使用${}
在由反引号包围的字符串中使用模板文字`
The code you pasted is not javascript, it is JSX and the {
and }
is how you embed expressions within it.您粘贴的代码不是 javascript,它是JSX , {
和}
是您在其中嵌入表达式的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.