![](/img/trans.png)
[英]How to add custom data-* attributes in react-bootstrap component
[英]How to add data- attributes in Checkbox component via inputProps
我使用用React + Typescript編寫的Fabric組件,當使用Checkbox組件時,我可以添加自定義屬性,例如data-id
等-這也寫在文檔上: https : //developer.microsoft.com/zh-cn/fabric #/組件/復選框
有什么問題 ? 我不知道如何通過將其傳遞給inputProps
來添加一個。
用於字段data
的React HTMLAttribute
接口需要string
值。
從我所見,React的HTMLAttribute
接口是通用接口,而Checkbox組件則在那里傳遞該接口: https : //github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/global.d.ts-它們為空。
有人知道如何在那里實現data-
屬性嗎?
在大多數接口擴展了React.ButtonAttributes的情況下,我們會過濾掉所有有效的按鈕道具(包括詠嘆調)並將其通過管道輸入。似乎此組件從未更新過以使用該方法,並且仍在使用舊方法將所有那些道具變成“ inputProps”。
<Checkbox
label="Standard checkbox"
inputProps={{'data-foo': 'bar'}}
ariaDescribedBy={'descriptionID'} />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.