@@ -3,7 +3,7 @@ import { Steps, StepItem } from 'tdesign-mobile-react';
33import { CartIcon } from 'tdesign-icons-react' ;
44
55export default function StepsDemo ( ) {
6- const [ first , setFirst ] = useState ( 1 ) ;
6+ const [ first , setFirst ] = useState < number | string > ( '1' ) ;
77 const [ second , setSecond ] = useState ( 1 ) ;
88 const [ third , setThird ] = useState ( 1 ) ;
99 const options = {
@@ -13,7 +13,7 @@ export default function StepsDemo() {
1313 } ;
1414
1515 const count = 4 ;
16- const onFirstChange = ( current : number ) => {
16+ const onFirstChange = ( current : number | string ) => {
1717 setFirst ( current ) ;
1818 } ;
1919 const onSecondChange = ( current : number ) => {
@@ -23,14 +23,17 @@ export default function StepsDemo() {
2323 setThird ( current ) ;
2424 } ;
2525
26- const getTitle = ( type : 'first' | 'second' | 'third' , index : number ) => {
27- if ( index === options [ type ] ) {
26+ const getTitle = ( type : 'first' | 'second' | 'third' , index : number | string ) => {
27+ const numIndex = Number ( index ) ;
28+ const currentValue = Number ( options [ type ] ) ;
29+
30+ if ( numIndex === currentValue ) {
2831 return '当前步骤' ;
2932 }
30- if ( index < options [ type ] ) {
33+ if ( numIndex < currentValue ) {
3134 return '已完成' ;
3235 }
33- if ( index > options [ type ] ) {
36+ if ( numIndex > currentValue ) {
3437 return '未完成' ;
3538 }
3639 } ;
0 commit comments