reactjs - 无法将样式应用于 react-native-progress-steps
问题描述
我一直在尝试将样式应用于 react-native-progress-steps 但它在我的应用程序中不起作用。我将样式应用于组件View
,ProgressSteps
但它没有显示在我的应用程序中。
<View style={{flex: 1}}>
<ProgressSteps style={styles.progressStepsStyle}>
<ProgressStep label="Information">
<View style={{ alignItems: 'center' }}>
<Text>This is the content within step 1!</Text>
</View>
</ProgressStep>
<ProgressStep label="Account">
<View style={{ alignItems: 'center' }}>
<Text>This is the content within step 2!</Text>
</View>
</ProgressStep>
<ProgressStep label="Completion">
<View style={{ alignItems: 'center' }}>
<Text>This is the content within step 3!</Text>
</View>
</ProgressStep>
<ProgressStep label="Verification">
<View style={{ alignItems: 'center' }}>
<Text>This is the content within step 4!</Text>
</View>
</ProgressStep>
</ProgressSteps>
</View>
</View>
这是图书馆的链接:https ://www.npmjs.com/package/react-native-progress-steps
解决方案
其实很简单。
您必须创建一个常量并在谁是锁定 ProgressStep 的父亲中调用它。
例如:
const progressStepsStyle = {
activeStepIconBorderColor: '#0a0d64',
activeLabelColor: '#0a0d64',
activeStepNumColor: 'white',
activeStepIconColor: '#0a0d64',
completedStepIconColor: '#0a0d64',
completedProgressBarColor: '#0a0d64',
completedCheckColor: 'white'
};
然后调用它:
<ProgressSteps {...progressStepsStyle}>
<ProgressStep label="Information">
<View style={{ alignItems: 'center' }}>
<Text>This is the content within step 1!</Text>
</View>
</ProgressStep>
<ProgressStep label="Account">
<View style={{ alignItems: 'center' }}>
<Text>This is the content within step 2!</Text>
</View>
</ProgressStep>
<ProgressStep label="Completion">
<View style={{ alignItems: 'center' }}>
<Text>This is the content within step 3!</Text>
</View>
</ProgressStep>
<ProgressStep label="Verification">
<View style={{ alignItems: 'center' }}>
<Text>This is the content within step 4!</Text>
</View>
</ProgressStep>
</ProgressSteps>
因此,您的圈子和进度条中都会有样式。
如果要设置按钮和按钮文本的样式,则必须将以下属性放在 nextBtnStyle、nextBtnTextStyle、previousBtnStyle 和 previousBtnTextStyle 中。
例如:
<ProgressStep nextBtnText={"Next"} nextBtnStyle={{ textAlign: 'center', padding: 8, backgroundColor: '#F8CC23', }} nextBtnTextStyle={{ color: '#007aff', fontSize: 18 }}>
推荐阅读
- python - 尝试使用支持向量机进行分类时出现值错误
- c# - 如何从 Postman 测试 web api 的多个可选参数
- javascript - 如何从 Vue 中的源更新音频?
- python-3.x - 我使用导入 numpy 编写的代码给出了错误
- c# - 使用 4 个连接通过 Territories 表列出所有销售区域的销售总计
- php - 使用wamp服务器通过php将表单数据输入数据库
- javascript - 如果会话存在不工作,则加载引导模式
- python-3.x - Tensorflow 和 keras:与 (None,H,W,C) 张量相关的自定义层和 model.fit 的问题
- c++ - 当使用 Lua 作为嵌入式语言时,例如 c++,是否有任何简单/方便的方法可以找到在 Lua 中定义变量的位置?
- netlogo - 为什么 globals [ x ] 通过编辑器检查但 globals [ E ] 给出了预期的错误右括号?