Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/zh/renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ checkboxEl.setAttribute('checked', 'false')
一些特殊的 `attribute`,比如 `checked/disabled` 等,只要出现了,对应的 `property` 就会被初始化为 `true`,无论设置的值是什么,只有调用 `removeAttribute` 删除这个 `attribute`,对应的 `property` 才会变成 `false`。
:::

这就指引我们有些属性不能通过 `setAttribute` 设置,而是应该直接通过 DOM 元素设置:`el.checked = true`。好在这样的属性不多,我们可以列举出来:`value`、`checked`、`selected`、`muted`。除此之外还有一些属性也需要使用 `Property` 的方式设置到 DOM 元素上,例如 `innerHTML` 和 `textContent` 等等。
这就指引我们有些属性不能通过 `setAttribute` 设置,而是应该直接通过 DOM 元素设置:`el.checked = true`。好在这样的属性不多,我们可以列举出来:`disabled`、`checked`、`selected`、`muted`。除此之外还有一些属性也需要使用 `Property` 的方式设置到 DOM 元素上,例如 `innerHTML` 和 `textContent` 等等。

刚才我们讲解了为什么同样是写在标签上的属性,却要区分对待的原因,接下来我们进入正题,开始完成将属性应用到 DOM 元素上的实现,到目前为止,我们已经为 `VNodeData` 设计了三个属性,如下:

Expand Down