Android 反应本机垂直交付进度条
如何在React Native上设置垂直进度条 我需要制作一个传送条进度 **示例:驱动程序位于A点,需要转到B点…*您最好尝试以下库: 或者您可以创建一个自定义progressbar,它在React Native中非常简单。你可以试试Android 反应本机垂直交付进度条,android,ios,react-native,mobile,progress-bar,Android,Ios,React Native,Mobile,Progress Bar,如何在React Native上设置垂直进度条 我需要制作一个传送条进度 **示例:驱动程序位于A点,需要转到B点…*您最好尝试以下库: 或者您可以创建一个自定义progressbar,它在React Native中非常简单。你可以试试 <View style={{height: 50, width: '100%', flexDirection: 'row'}}> <View style={{height: '100%', flex: this.state.curre
<View style={{height: 50, width: '100%', flexDirection: 'row'}}>
<View style={{height: '100%', flex: this.state.currentProgress, backgroundColor: "blue"}}/>
<View style={{height: '100%', flex: 100 - this.state.currentProgress, backgroundColor: "grey"}}/>
</View>
我想是的。这有点棘手,但可以做到。您必须有一条垂直线,并以行格式水平放置项目 假设您有这样的数据结构。您可以使用标志更新当前位置并设置标签
const data = [
{ title: 'Stop 1', letter: 'A', isCurrent: false },
{ title: 'Stop 2', letter: 'B', isCurrent: false },
{ title: 'Stop 3', letter: 'C', isCurrent: false },
{ title: 'Stop 4', letter: 'D', isCurrent: true },
{ title: 'Stop 5', letter: 'E', isCurrent: false },
];
这将是处理地图的组件
const MapProgress = (props) => {
if (!props.data || props.data.lenght === 0) return null;
const firstItem = props.data.shift();
return (
<View style={{ flex: 1 }}>
<View style={styles.verticalLine}></View>
<View style={styles.verticalWrap}>
<View style={styles.itemWrap}>
<View style={styles.firstPoint}></View>
<View style={{ marginLeft: 5, flex: 1 }}>
<Text>{firstItem.title}</Text>
</View>
</View>
{props.data.map((item) => (
<View style={styles.itemWrap}>
<View style={styles.pointWrap}>
<Text
style={[
styles.markerText,
item.isCurrent ? styles.currentMarker : null,
]}>
{item.letter}
</Text>
</View>
<View style={{ marginLeft: 5, flex: 1 }}>
<Text style={item.isCurrent ? styles.currentMarker : null}>
{item.title}
</Text>
</View>
</View>
))}
</View>
</View>
);
};
您可以像这样使用组件
<MapProgress data={data} />
你可以试用下面的小吃
用于垂直进度条。你可以用手杖吗
react native progress
npm并使用样式转换属性简单地旋转条
import React from 'react';
import * as Progress from 'react-native-progress';
return <Progress progress={progress} style={{ transform: [{ rotate: '-90deg' }] }} />;
从“React”导入React;
将*作为进度从“反应本机进度”导入;
返回;
请参阅原答覆:
我编辑了我的问题并放了一张图片,你能帮我吗?它可以工作,但有一个错误:
警告:列表中的每个孩子都应该有一个唯一的“key”道具。
这是一个警告,你可以这样做,这将有助于对唯一标识项目做出反应
import React from 'react';
import * as Progress from 'react-native-progress';
return <Progress progress={progress} style={{ transform: [{ rotate: '-90deg' }] }} />;