React(JSX语法)----JSX拼写

不羁岁月 提交于 2019-11-26 20:37:04

注意:For DOM differences,such as the inline style attribute,check here.

// bad: it displays "FIrst &middot; second" <div>{'First &middot; Second'}</div>

  There are various ways to work-around this issue.The easiest one is to write unicode cahracter directly in JavaScript.You need to make sure the file is saved as UTF-8 and that the proper UTF-8 directive are set so the brower will display it correctly.

<div>{'First \u00b7 Second'}</div>
<div>{'First' + String.fromCharCode(183) + 'Second'}</div>

  

<div>{['First',<span>·</span>,'Second']}</div>

  

<div dangerouslySetInnerHTML = {{__html:'First · Second'}}>

 

  if you pass properties to native HTML elements that do not exist in the HTML specification,React will not render them. if you want to use a custom attribute,you should prefix it with data-

<div data-custom-attribute = "foo">

  web Accessibility attributes starting with aria- will be rendered properly.

<div aria-hidden = {true}>

  

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!