简体   繁体   中英

Handling 'content' - attribute in TSX?

I am working on an application that makes use of schema.org. I have the following line:

<span itemProp="priceCurrency" content="EUR">€</span>

Based on the schema.org docs the content attribute is allowed.

Note that both RDFa and Microdata syntax allow the use of a "content=" attribute for publishing simple machine-readable values alongside more human-friendly formatting.

However, I don't know how to fix this TS error: Property 'content' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>'

Grateful for any ideas!

This solved the TS-error:

declare module 'react' {
    interface HTMLAttributes<T> {
        // extends React's HTMLAttributes
        content?: string;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM