mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Full list of changes is at https://jekyllrb.com/docs/upgrading/2-to-3/. The tl;dr of it is: - Relative permalinks were removed, so all the files in the `docs` subdirectory need their permalink to be prefixed with `docs/` - `post` and `page` types were renamed to `posts` and `pages` respectively - `jekyll-paginate`, `pygments` and `redcarpet` are all now optional, so I needed to explicitly add it to the Gemfile. Jekyll now uses `rouge` rather than `pygments` for syntax highlighting, but rouge does not support highlighting individual lines (`hl_lines`) so we need to continue using Pygments. - Layout metadata (eg. `sectionid`) is now on a `layout` variable rather than `page` Tested the following pages and confirmed that they all work: - "Docs" link (getting started page): http://127.0.0.1:4000/react/docs/getting-started.html - Downloads: http://127.0.0.1:4000/react/downloads.html - Tutorial: http://127.0.0.1:4000/react/docs/tutorial.html - A few pages under the "docs" subdirectory, to confirm they're working properly: - http://127.0.0.1:4000/react/docs/addons.html - http://127.0.0.1:4000/react/docs/why-react.html - http://127.0.0.1:4000/react/docs/create-fragment.html - A few tips: - http://127.0.0.1:4000/react/tips/false-in-jsx.html - http://127.0.0.1:4000/react/tips/style-props-value-px.html - Non-English versions of the page: - http://127.0.0.1:4000/react/docs/getting-started-it-IT.html - http://127.0.0.1:4000/react/docs/getting-started-ja-JP.html
1.8 KiB
1.8 KiB
id, title, permalink, prev, next
| id | title | permalink | prev | next |
|---|---|---|---|---|
| dom-differences-zh-CN | DOM 的不同之处 | docs/dom-differences-zh-CN.html | events-zh-CN.html | special-non-dom-attributes-zh-CN.html |
React 实现了一个浏览器无关的 事件和DOM 系统,原因是为了性能和跨浏览器的兼容性.我们利用这个机会来清理了一些浏览器DOM实现的一些粗糙边缘.
- 所有的 DOM properties 和 attributes (包括事件处理器) 都应该 camelCased 来保持和标准的 JavaScript 风格一致.我们在这里故意打破了这个规范是因为规范是不一致的. 然而,
data-*和aria-*attributes conform to the specs 应该只 lower-cased. styleattribute 接受 camelCased properties 的JavaScript对象 而不是一个CSS字符串. 这保持了和 DOMstyleJavaScript property 的一致,更有效率,而且阻止了XSS安全漏洞.- 因为
class和for是 JavaScript的保留字,内建DOM nodes的JSX元素 应该分别使用 attribute名className和htmlFor,(比如<div className="foo" />).自定义元素应该直接使用class和for(例如.<my-tag class="foo" />). - 所有事件对象遵循 W3C 规范,所有事件(包括提交)正确按W3C规范冒泡.详见Event System.
onChange事件表现的像你期望的那样:不论何时一个表单域改变了这个事件就会激发,而不是模糊的不一致.我们故意打破了已有浏览器的行为,因为onChange对于他的行为来说用词不当,并且React依赖于这个事件来实时响应用户的输入.详见Forms.- 表单 输入attributes 类似
value和checked,就像textarea一样More here.