demo.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="demo padding">
  3. <h2>基本用法</h2>
  4. <div class="steps-wrapper">
  5. <nut-steps :current="current1" @click-step="handleClickStep">
  6. <nut-step title="步骤一">
  7. 1
  8. <template v-slot:title>步骤一</template>
  9. </nut-step>
  10. <nut-step title="步骤二">2</nut-step>
  11. <nut-step title="步骤三">3</nut-step>
  12. </nut-steps>
  13. <div class="steps-button">
  14. <nut-button size="mini" type="primary" @click="handleStep('current1')">下一步</nut-button>
  15. </div>
  16. </div>
  17. <h2>标题和描述信息</h2>
  18. <div class="steps-wrapper">
  19. <nut-steps :current="current2">
  20. <nut-step title="步骤一" content="步骤描述">1</nut-step>
  21. <nut-step title="步骤二" content="步骤描述"></nut-step>
  22. <nut-step title="步骤三" content="步骤描述"></nut-step>
  23. </nut-steps>
  24. <div class="steps-button" style="margin-top: 10px">
  25. <nut-button size="mini" type="primary" @click="handleStep('current2')">下一步</nut-button>
  26. </div>
  27. </div>
  28. <h2>自定义图标</h2>
  29. <div class="steps-wrapper">
  30. <nut-steps current="1">
  31. <nut-step title="已完成" icon="service">1</nut-step>
  32. <nut-step title="进行中" icon="people">2</nut-step>
  33. <nut-step title="未开始" icon="location2">3</nut-step>
  34. </nut-steps>
  35. </div>
  36. <h2>竖向步骤条</h2>
  37. <div class="steps-wrapper" style="height: 300px; padding: 15px 30px">
  38. <nut-steps direction="vertical" current="2">
  39. <nut-step title="已完成" content="您的订单已经打包完成,商品已发出">1</nut-step>
  40. <nut-step title="进行中" content="您的订单正在配送途中">2</nut-step>
  41. <nut-step title="未开始" content="收货地址为:北京市经济技术开发区科创十一街18号院京东大厦">3</nut-step>
  42. </nut-steps>
  43. </div>
  44. <h2>竖向步骤条</h2>
  45. <div class="steps-wrapper" style="height: 300px; padding: 15px 40px">
  46. <nut-steps direction="vertical" progress-dot current="2">
  47. <nut-step title="已完成" content="您的订单已经打包完成,商品已发出">1</nut-step>
  48. <nut-step title="进行中" content="您的订单正在配送途中">2</nut-step>
  49. <nut-step title="未开始"
  50. >3
  51. <template v-slot:content>
  52. <p>收货地址为:</p>
  53. <p>北京市经济技术开发区科创十一街18号院京东大厦</p>
  54. </template>
  55. </nut-step>
  56. </nut-steps>
  57. </div>
  58. </div>
  59. </template>
  60. <script lang="ts">
  61. import { reactive, toRefs } from 'vue';
  62. import { createComponent } from '../../utils/create';
  63. const { createDemo } = createComponent('steps');
  64. export default createDemo({
  65. props: {},
  66. setup() {
  67. const state = reactive({
  68. current1: 1,
  69. current2: 1,
  70. current3: 1,
  71. current4: 1,
  72. current5: 1
  73. });
  74. const handleStep = (params) => {
  75. if (state[params] >= 3) {
  76. state[params] = 1;
  77. } else {
  78. state[params] += 1;
  79. }
  80. };
  81. const handleClickStep = (index: number) => {
  82. console.log(index);
  83. };
  84. return {
  85. ...toRefs(state),
  86. handleStep,
  87. handleClickStep
  88. };
  89. }
  90. });
  91. </script>
  92. <style lang="scss">
  93. .padding {
  94. padding-left: 0 !important;
  95. padding-right: 0 !important;
  96. h2 {
  97. padding-left: 27px !important;
  98. }
  99. }
  100. .steps-wrapper {
  101. width: 100%;
  102. padding: 15px 0;
  103. background-color: #fff;
  104. .steps-button {
  105. text-align: center;
  106. }
  107. }
  108. </style>