MultiComponentMixin.js 734 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. export default {
  2. data() {
  3. return {
  4. activeStep: 1,
  5. steps: []
  6. }
  7. },
  8. computed : {
  9. stepsLength() {
  10. return this.steps.length
  11. },
  12. isLastStep() {
  13. return this.activeStep === this.stepsLength
  14. },
  15. isFirstStep() {
  16. return this.activeStep === 1
  17. },
  18. progress() {
  19. return `${100 / this.stepsLength * this.activeStep}%`
  20. },
  21. activeComponent() {
  22. return this.steps[this.activeStep - 1]
  23. }
  24. },
  25. methods:{
  26. nextStep (){
  27. this.activeStep++
  28. },
  29. previousStep (){
  30. this.activeStep--
  31. },
  32. navigateTo(step){
  33. this.activeStep = step
  34. },
  35. activeComponentClass(step){
  36. return this.activeStep === step ? 'is-active' : ''
  37. }
  38. }
  39. }