我试图了解这件事是如何工作的,但我发现的所有示例都是以课堂方式编写的。
import React from 'react'
import styled from 'styled-components/native'
const MyTag = styled.Button.attrs({
title: myThisThingValue
})`
// some style
background: thisIsAlsoMyThingValue
\`
export default function MyComponent({ props }) {
return(
<MyTag myThisThing="My value" thisIsAlsoMyThing="Other Value" />
)
}
Run Code Online (Sandbox Code Playgroud)
我只想访问 MyTag 样式中的自定义属性。我(props) => {title: props.MyThing }在 .attrs() 中使用了 a但没有用。
javascript reactjs react-native react-native-android styled-components