Steps 步骤条
import { TaSteps, TaIcon, TaFixed, TaButton, TaGroup } from '@/index'
import { useState } from 'react'
const steps = [
{
title: '已完成',
content: '这一步过了哈'
},
{
title: '进行中',
content: '目前到这一步'
},
{
title: '待处理',
content: '还没到这一步'
}
]
const orderSteps = [
{
content: '买家下单'
},
{
content: '商家接单'
},
{
content: '商家发货'
},
{
content: '买家提货'
},
{
content: '交易完成'
}
]
export default function ExpSteps() {
const [stepIndex, setStepIndex] = useState(1)
const renderItems = () => {
return steps.map((item, index) => (
<TaSteps.Step key={index} title={item.title}>
{item.content}
</TaSteps.Step>
))
}
const renderOrderItems = () => {
return orderSteps.map((item, index) => (
<TaSteps.Step key={index}>{item.content}</TaSteps.Step>
))
}
const renderIconItems = () => {
return steps.map((item, index) => (
<TaSteps.Step
key={index}
title={item.title}
renderStep={({ finish, active }) => (
<>
{finish ? (
<TaIcon icon="CheckOutlined"></TaIcon>
) : active ? (
<TaIcon icon="LoadingOutlined" spin></TaIcon>
) : (
<></>
)}
</>
)}
>
{item.content}
</TaSteps.Step>
))
}
return (
<>
<TaGroup title="基础用法">
<TaSteps activeIndex={stepIndex}>{renderItems()}</TaSteps>
</TaGroup>
<TaGroup title="小点模式">
<TaSteps activeIndex={stepIndex} dot>
{renderItems()}
</TaSteps>
</TaGroup>
<TaGroup title="自定义图标">
<TaSteps activeIndex={stepIndex}>{renderIconItems()}</TaSteps>
</TaGroup>
<TaGroup title="横向">
<TaSteps activeIndex={stepIndex} horizontal>
{renderItems()}
</TaSteps>
</TaGroup>
<TaGroup title="横向(不要标题 & 小点)">
<TaSteps activeIndex={1} horizontal dot>
{renderOrderItems()}
</TaSteps>
</TaGroup>
<TaGroup title="renderTitle">
<TaSteps>
<TaSteps.Step title="【珠海市】快件已送达【正方云创园】,感谢您使用中通快递">
2021-04-13 12:42:57
</TaSteps.Step>
<TaSteps.Step
renderTitle={() => (
<>
【珠海市】【珠海一部】快递小哥正在派件(
<a href="tel:10000">10000</a>)
</>
)}
>
2021-04-13 11:22:16
</TaSteps.Step>
<TaSteps.Step title="【珠海市】快件离开【珠海中心】已发往【珠海一部】">
2021-04-13 09:04:03
</TaSteps.Step>
</TaSteps>
</TaGroup>
<TaFixed>
<div className="exp-steps-next">
<TaButton
onClick={() =>
setStepIndex(stepIndex => (stepIndex + 1) % steps.length)
}
type="primary"
>
下一步
</TaButton>
</div>
</TaFixed>
</>
)
}
Import
import { TaSteps, TaStep } from 'tantalum-ui-mobile-react'
具体的引入方式可以参考引入组件。
Steps
Steps Props
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
activeIndex | number | 0 | 否 | 当前步骤对应的索引值 |
dot | boolean | false | 否 | 是否开启小点样式 |
Steps Slots
children
注:其中只可放置 Step 组件,否则会导致未定义的行为。
<TaSteps>
<TaSteps.Step title="标题">自定义内容</TaSteps.Step>
</TaSteps>
Step
Step Props
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
title | string | 否 | 步骤子项标题 |
Step Slots
内容(children)
<TaSteps.Step title="标题">自定义内容</TaSteps.Step>
标题(renderTitle)
<TaSteps.Step
renderTitle={() => (
<>
【珠海市】【珠海一部】快递小哥正在派件(
<a href="tel:10000">10000</a>)
</>
)}
>
2021-04-13 11:22:16
</TaSteps.Step>
注:优先级高于 Props title
。
步骤标(renderStep)
<TaSteps.Step
key={index}
title={item.title}
renderStep={({ finish, active }) => (
<>
{finish ? (
<TaIcon icon="CheckOutlined"></TaIcon>
) : active ? (
<TaIcon icon="LoadingOutlined" spin></TaIcon>
) : (
<></>
)}
</>
)}
>
{item.content}
</TaSteps.Step>
注:只推荐写入 text 和 Icon 组件,其他元素或组件可能会导致未定义的行为。