React native 如何在其他样式化组件中使用样式化组件中的边距 从“React”导入React; 从“样式化组件/本机”导入样式化; 从“react native”导入{Text,View}; 导出默认函数HelloWorldApp(){ 返回( 你好,世界 你好,世界 ); } const StyledBody=styled.View` `; const StyledBody2=styled(StyledBody)` //它不起作用 利润率:20px; `;
在react native中,边距在其他样式化组件内部的样式化组件中使用时不起作用。我需要特定的方式样式化(StyledBody)React native 如何在其他样式化组件中使用样式化组件中的边距 从“React”导入React; 从“样式化组件/本机”导入样式化; 从“react native”导入{Text,View}; 导出默认函数HelloWorldApp(){ 返回( 你好,世界 你好,世界 ); } const StyledBody=styled.View` `; const StyledBody2=styled(StyledBody)` //它不起作用 利润率:20px; `;,react-native,styled-components,React Native,Styled Components,在react native中,边距在其他样式化组件内部的样式化组件中使用时不起作用。我需要特定的方式样式化(StyledBody) import React from 'react'; import styled from 'styled-components/native'; import { Text, View } from 'react-native'; export default function HelloWorldApp() { return ( <>
import React from 'react';
import styled from 'styled-components/native';
import { Text, View } from 'react-native';
export default function HelloWorldApp() {
return (
<>
<StyledBody2>
<Text>Hello, world!1</Text>
</StyledBody2>
<Text>Hello, world!2</Text>
</>
);
}
const StyledBody = styled.View`
`;
const StyledBody2 = styled(StyledBody)`
//it doesn't work
margin: 20px;
`;