docs: improve content accuracy (#424)

This commit is contained in:
MonsterPi 2024-03-31 18:04:54 +08:00 committed by GitHub
parent 632ab54d8f
commit ece5255819
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -2,7 +2,7 @@
title: '`data-`属性有什么用?'
---
在 JavaScript 框架流行之前,开发者使用`data-`属性在 DOM 本身中存储额外的数据,没有其他的黑客如非标准属性DOM 上的额外属性。 它是为了在没有更合适的属性或元素时将自定义数据私密存储到页面或应用中。
在 JavaScript 框架流行之前,开发者使用`data-`属性在 DOM 本身中存储额外的数据,没有其他的技巧如非标准属性DOM上的额外属性。 它是为了在没有更合适的属性或元素时将自定义数据私密存储到页面或应用中。
“data-”属性的另一个常用例子是存储第三方库或框架使用的信息。 例如Bootstrap 库使用数据属性使`<button>`s 在页面的其他地方触发 modal 的动作([example](https://getbootstrap.com/docs/5.2/components/modal/#via-data-attributes))。