我试图使React Native中的样式表能够使用动态值,但我不知道如何声明它,我们可以更改React Native样式表的样式名称吗?
您可以通过这种方式在 React Native 中声明样式表
import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
export default function App() {
return (
<View style={styles.container}>
<Text style={styles.welcomeText}>welcome</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: 10,
backgroundColor: '#ecf0f1',
padding: 8,
},
welcomeText:{
color:'red',
},
});
在文档中阅读相关内容这里。
这也许就是您正在寻找的。