[英]How do you escape quotes in reactjs
I have issues with escaping quotes on my react app.我的 React 应用程序中的 escaping 引号有问题。
<textarea id="values"
placeholder="{ "name": "John", "test": true}"
onChange={this.handleChange2.bind(this)}>
</textarea>
I have tried to do this:我试过这样做:
<textarea id="values"
placeholder="{ \"name\": \"John\", \"test\": true}"
onChange={this.handleChange2.bind(this)}>
</textarea>
But that does not work for me.但这对我不起作用。
Try using single quotes instead. 尝试改用单引号。
<textarea id="values"
placeholder='{ "name": "John", "test": true}'
onChange={this.handleChange2.bind(this)}>
</textarea>
OR 要么
move the quotes inside {} 将引号移到{}内
<textarea id="values"
placeholder={"\"name\": \"John\", \"test\": true"}
onChange={this.handleChange2.bind(this)}>
</textarea>
And if you want to pass in values, you could use template literal as well 如果您要传递值,也可以使用模板文字
<textarea
id="values"
placeholder={`"name": "John", "test": ${value}`}
onChange={this.handleChange2.bind(this)}
/>
<p>"What if this? what if that?"</p>
"What if this? what if that?"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.