JavaScript/react/自定义参数:修订间差异
来自康健生活
创建页面,内容为“== 引言 == == 参数 == <syntaxhighlight lang="javascript"> const params = 100; const handle = (event: any) => { // 获取所有自定义属性 // e.target.dat…” |
|||
| 第10行: | 第10行: | ||
}; | }; | ||
... | ... | ||
<component data-key={params} /> | <component data-key={params} onClick={handle} /> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Warning|<code>event.target.getAttribute</code> 会将 number 变为 string}} | {{Warning|<code>event.target.getAttribute</code> 会将 number 变为 string}} | ||