使用样式表在本机反应中的样式系统

问题描述 投票:0回答:2

我试图使React Native中的样式表能够使用动态值,但我不知道如何声明它,我们可以更改React Native样式表的样式名称吗?

javascript react-native mobile native react-native-stylesheet
2个回答
0
投票

您可以通过这种方式在 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',
 },
 });

在文档中阅读相关内容这里


0
投票

我是rn风格系统的作者

这也许就是您正在寻找的。

© www.soinside.com 2019 - 2024. All rights reserved.