Steps 步骤条

Scan me!

用于引导用户按照流程完成任务的导航条,显示当前所在步骤

引入

  1. import { Steps } from 'mand-mobile'
  2. Vue.component(Steps.name, Steps)

代码演示

三个步骤

  1. <template>
  2. <div class="md-example-child md-example-child-steps md-example-child-steps-0">
  3. <md-steps
  4. :steps="steps">
  5. </md-steps>
  6. </div>
  7. </template>
  8. <script>
  9. import {Steps} from 'mand-mobile'
  10. export default {
  11. name: 'steps-demo',
  12. components: {
  13. [Steps.name]: Steps,
  14. },
  15. data() {
  16. return {
  17. steps: [
  18. {
  19. name: '开通理财账户',
  20. },
  21. {
  22. name: '验证手机号',
  23. },
  24. {
  25. name: '开通成功',
  26. },
  27. ],
  28. }
  29. },
  30. }
  31. </script>

自定义步骤图标

  1. <template>
  2. <div class="md-example-child md-example-child-steps md-example-child-steps-2">
  3. <md-steps
  4. :steps="steps"
  5. :current="2">
  6. <div slot="reached" slot-scope="props">
  7. <!-- props.index -->
  8. <md-icon name="circle-alert" size="lg"></md-icon>
  9. </div>
  10. <div slot="current" slot-scope="props">
  11. <!-- props.index -->
  12. <md-icon name="hollow-plus" size="lg"></md-icon>
  13. </div>
  14. </md-steps>
  15. </div>
  16. </template>
  17. <script>
  18. import {Steps, Icon} from 'mand-mobile'
  19. export default {
  20. name: 'steps-demo',
  21. components: {
  22. [Steps.name]: Steps,
  23. [Icon.name]: Icon,
  24. },
  25. data() {
  26. return {
  27. steps: [
  28. {
  29. name: '开通理财账户',
  30. },
  31. {
  32. name: '验证手机号',
  33. },
  34. {
  35. name: '开通成功',
  36. },
  37. ],
  38. }
  39. },
  40. }
  41. </script>

动态修改当前所处步骤 current = 2

  1. <template>
  2. <div class="md-example-child md-example-child-steps md-example-child-steps-4">
  3. <md-steps
  4. :steps="steps"
  5. :current="currentStep">
  6. </md-steps>
  7. </div>
  8. </template>
  9. <script>
  10. import {Steps} from 'mand-mobile'
  11. export default {
  12. name: 'steps-demo',
  13. components: {
  14. [Steps.name]: Steps,
  15. },
  16. mounted() {
  17. window.triggerSteps0 = () => {
  18. this.currentStep = 2
  19. }
  20. },
  21. data() {
  22. return {
  23. steps: [
  24. {
  25. name: '登录',
  26. },
  27. {
  28. name: '开通',
  29. },
  30. {
  31. name: '验证',
  32. },
  33. {
  34. name: '成功',
  35. },
  36. ],
  37. currentStep: 0,
  38. }
  39. },
  40. }
  41. </script>

完成全部步骤

  1. <template>
  2. <div class="md-example-child md-example-child-steps md-example-child-steps-5">
  3. <md-steps
  4. :steps="steps"
  5. :current="currentStep">
  6. </md-steps>
  7. </div>
  8. </template>
  9. <script>
  10. import {Steps} from 'mand-mobile'
  11. export default {
  12. name: 'steps-demo',
  13. components: {
  14. [Steps.name]: Steps,
  15. },
  16. data() {
  17. return {
  18. steps: [
  19. {
  20. name: '登录',
  21. },
  22. {
  23. name: '开通',
  24. },
  25. {
  26. name: '验证',
  27. },
  28. {
  29. name: '成功',
  30. },
  31. ],
  32. currentStep: 4,
  33. }
  34. },
  35. }
  36. </script>
  37. <style lang="stylus">
  38. .md-example-child-steps-5
  39. height 140px
  40. .md-steps .icon.current::before
  41. content ''
  42. color color-primary-tap
  43. border-bottom 10px solid
  44. border-left 10px solid transparent
  45. border-right 10px solid transparent
  46. position absolute
  47. top 130px
  48. </style>
  49.  

四个步骤

  1. <template>
  2. <div class="md-example-child md-example-child-steps md-example-child-steps-1">
  3. <md-steps
  4. :steps="steps">
  5. </md-steps>
  6. </div>
  7. </template>
  8. <script>
  9. import {Steps} from 'mand-mobile'
  10. export default {
  11. name: 'steps-demo',
  12. components: {
  13. [Steps.name]: Steps,
  14. },
  15. data() {
  16. return {
  17. steps: [
  18. {
  19. name: '登录',
  20. },
  21. {
  22. name: '开通',
  23. },
  24. {
  25. name: '验证',
  26. },
  27. {
  28. name: '成功',
  29. },
  30. ],
  31. }
  32. },
  33. }
  34. </script>

指定当前步骤

  1. <template>
  2. <div class="md-example-child md-example-child-steps md-example-child-steps-3">
  3. <md-steps
  4. :steps="steps"
  5. :current="2">
  6. </md-steps>
  7. </div>
  8. </template>
  9. <script>
  10. import {Steps} from 'mand-mobile'
  11. export default {
  12. name: 'steps-demo',
  13. components: {
  14. [Steps.name]: Steps,
  15. },
  16. data() {
  17. return {
  18. steps: [
  19. {
  20. name: '登录',
  21. },
  22. {
  23. name: '开通',
  24. },
  25. {
  26. name: '验证',
  27. },
  28. {
  29. name: '成功',
  30. },
  31. ],
  32. }
  33. },
  34. }
  35. </script>

利用current类增加自定义样式

  1. <template>
  2. <div class="md-example-child md-example-child-steps md-example-child-steps-5">
  3. <md-steps
  4. :steps="steps"
  5. :current="currentStep">
  6. </md-steps>
  7. </div>
  8. </template>
  9. <script>
  10. import {Steps} from 'mand-mobile'
  11. export default {
  12. name: 'steps-demo',
  13. components: {
  14. [Steps.name]: Steps,
  15. },
  16. data() {
  17. return {
  18. steps: [
  19. {
  20. name: '登录',
  21. },
  22. {
  23. name: '开通',
  24. },
  25. {
  26. name: '验证',
  27. },
  28. {
  29. name: '成功',
  30. },
  31. ],
  32. currentStep: 1,
  33. }
  34. },
  35. }
  36. </script>
  37. <style lang="stylus">
  38. .md-example-child-steps-5
  39. height 140px
  40. .md-steps .icon.current::before
  41. content ''
  42. color color-primary-tap
  43. border-bottom 10px solid
  44. border-left 10px solid transparent
  45. border-right 10px solid transparent
  46. position absolute
  47. top 130px
  48. </style>
  49.  

API

Tabs Props

属性说明类型默认值备注
steps步骤信息数组Array-数组中每个元素须包含name属性,会作为步骤名称显示
current当前步骤Number0可通过修改该值动态改变当前所在步骤