/* 进度条组件 * @Author: cellerchan * @Date: 2019-03-06 16:15:10 * @Last Modified by: cellerchan * @Last Modified time: 2019-09-29 23:40:27 * * params * @currentIndex 当前进度索引 Number * @textArr 文字数组 String Array */ import Taro, { Component } from '@tarojs/taro'; import { View, Text, Image } from '@tarojs/components'; import './index.scss'; /** * IProps */ interface IProps { currentIndex: number; textArr: Array; } class ProgressBar extends Component { /** * render */ render() { const { currentIndex, textArr } = this.props; return ( {/* 文字 */} {textArr.map((item, index) => { return ( {item} ); })} {/* 进度条 */} {textArr.map((item, index) => { return ( {/* 当前所在索引显示大圆 否则显示小圆 */} {index === currentIndex ? ( ) : ( = currentIndex ? '#ddd' : '#EC4C39' }} /> )} {/* 除最后一条之外显示连接线 */} {index !== textArr.length - 1 ? ( = currentIndex ? '#ddd' : '#EC4C39' }} /> ) : null} ); })} ); } } export default ProgressBar;