You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< script >
import Steps , { Step } from '../index' ;
import '../assets/index.less' ;
import '../assets/iconfont.less' ;
function generateRandomSteps ( ) {
const n = Math . floor ( Math . random ( ) * 3 ) + 3 ;
const arr = [ ] ;
for ( let i = 0 ; i < n ; i ++ ) {
arr . push ( {
title : ` 步骤 ${ ( i + 1 ) } ` ,
} ) ;
}
return arr ;
}
const steps = generateRandomSteps ( ) ;
export default {
data ( ) {
return {
currentStep : Math . floor ( Math . random ( ) * steps . length ) ,
} ;
} ,
methods : {
nextStep ( ) {
let s = this . currentStep + 1 ;
if ( s === steps . length ) {
s = 0 ;
}
this . currentStep = s ;
} ,
} ,
render ( ) {
const cs = this . currentStep ;
return (
< form class = 'my-step-form' >
< div > 这个demo随机生成3 ~ 6 个步骤 , 初始随机进行到其中一个步骤 < / div >
< div > 当前正在执行第 { cs + 1 } 步 < / div >
< div class = 'my-step-container' >
< Steps current = { cs } >
{
steps . map ( ( s , i ) => {
return (
< Step
key = { i }
title = { s . title }
/ >
) ;
} )
}
< / Steps >
< / div >
< div > < button type = 'button' onClick = { this . nextStep } > 下一步 < / button > < / div >
< / form >
) ;
} ,
} ;
< / script >
< style >
. my - step - form {
width : 100 % ;
}
. my - step - form > div {
margin - bottom : 20 px ;
}
. my - step - container {
width : 100 % ;
}
< / style >