为什么占位符属性中的 &#10 和 &#32 在浏览器中不起作用

why the &#10 and &#32 in the placeholder attribute doesn't work in the browser

关于 "&#10" 和“ ”如何在占位符属性中协同工作的问题。这是我的代码:

render() {
 return(
   <div>{
      if this.state.showTextarea?
      <div> 
        <form> 
         <textarea  placeholder='ex:&#10;{"data":{&#10;&#32;"name":"petter"&#10;}&#10;}'> </textarea>
        </form>
      </div>
      : null
   } 
   </div>
);
}

显示如下:

如果在代码片段上 运行 效果很好,但在浏览器(chrome 和 Edge)中不起作用。 有什么想法吗?

它不是标准的一部分。您可以使用 Javascript 来完成。 https://github.com/bradjasper/jQuery-Placeholder-Newlines