Reactjs Emotion.js如何在react native中进行合成/条件造型?
举例说明Reactjs Emotion.js如何在react native中进行合成/条件造型?,reactjs,react-native,emotion,Reactjs,React Native,Emotion,举例说明 style={css` border-radius: 10px; `} 但是,我不知道如何才能像react native中那样进行合成 <div css={[danger, base]}> 即使我能做到,他们也会使用两种不同的方法,一种是使用css,另一种是使用styled。如何使用react-native同时获得这两种功能?问题1:如何在react-native中使用情绪/本族语进行合成 const Description = st
style={css`
border-radius: 10px;
`}
但是,我不知道如何才能像react native中那样进行合成
<div css={[danger, base]}>
即使我能做到,他们也会使用两种不同的方法,一种是使用css
,另一种是使用styled
。如何使用react-native同时获得这两种功能?问题1:如何在react-native中使用情绪/本族语进行合成
const Description = styled.Text`
font-size: ${props => props.fontSize !== undefined ? props.fontSize : "40px"};
color: hotpink;
`
<Description fontSize={"60px"}>
Change code in the editor and watch it change on your phone! Save to get a shareable url.
</Description>
非常简单,只需使用样式属性,如下所示:
const style1 = css`
font-size: 40px;
`
const color = css`
color: red;
`
// And then in your component you can pass the all your style objects
// in an array to style property
<Text style={[fontSize, color]}>Hello world</Text>
这里有一个工作实例作为一个例子
const Description = styled.Text`
font-size: ${props => props.fontSize !== undefined ? props.fontSize : "40px"};
color: hotpink;
`
<Description fontSize={"60px"}>
Change code in the editor and watch it change on your phone! Save to get a shareable url.
</Description>