Progressbar - 图1

Progressbar Vue Component

Progressbar Vue component represents Progressbar element.

Progressbar Components

There are following components included:

  • **f7-progressbar**

Progressbar Properties

PropTypeDescription
<f7-progressbar> properties
progressnumberDeterminate progress (from 0 to 100)
infinitebooleanWhether progressbar is infinite or not (determinate)

Progressbar Methods

<f7-progressbar> methods
.set(progress, duration)Set progressbar progress

Examples

  1. <template>
  2. <f7-page>
  3. <f7-navbar title="Progress Bar"></f7-navbar>
  4. <f7-block-title>Determinate Progress Bar</f7-block-title>
  5. <f7-block strong>
  6. <p>When progress bar is determinate it indicates how long an operation will take when the percentage complete is detectable.</p>
  7. <p>Inline determinate progress bar:</p>
  8. <div>
  9. <p><f7-progressbar :progress="10" id="demo-inline-progressbar"></f7-progressbar></p>
  10. <f7-segmented raised>
  11. <f7-button @click="setInlineProgress(10)">10%</f7-button>
  12. <f7-button @click="setInlineProgress(30)">30%</f7-button>
  13. <f7-button @click="setInlineProgress(50)">50%</f7-button>
  14. <f7-button @click="setInlineProgress(100)">100%</f7-button>
  15. </f7-segmented>
  16. </div>
  17. <div>
  18. <p>Inline determinate load & hide:</p>
  19. <p id="demo-determinate-container"></p>
  20. <p>
  21. <f7-button raised @click="showDeterminate(true)">Start Loading</f7-button>
  22. </p>
  23. </div>
  24. <div>
  25. <p>Overlay with determinate progress bar on top of the app:</p>
  26. <p>
  27. <f7-button raised @click="showDeterminate(false)">Start Loading</f7-button>
  28. </p>
  29. </div>
  30. </f7-block>
  31. <f7-block-title>Infinite Progress Bar</f7-block-title>
  32. <f7-block strong>
  33. <p>When progress bar is infinite/indeterminate it requests that the user wait while something finishes when it’s not necessary to indicate how long it will take.</p>
  34. <p>Inline infinite progress bar</p>
  35. <p>
  36. <f7-progressbar infinite></f7-progressbar>
  37. </p>
  38. <p>Multi-color infinite progress bar</p>
  39. <p>
  40. <f7-progressbar infinite color="multi"></f7-progressbar>
  41. </p>
  42. <div>
  43. <p>Overlay with infinite progress bar on top of the app</p>
  44. <p id="demo-infinite-container"></p>
  45. <p>
  46. <f7-button raised @click="showInfinite(false)">Start Loading</f7-button>
  47. </p>
  48. </div>
  49. <div>
  50. <p>Overlay with infinite multi-color progress bar on top of the app</p>
  51. <p>
  52. <f7-button raised @click="showInfinite(true)">Start Loading</f7-button>
  53. </p>
  54. </div>
  55. </f7-block>
  56. <f7-block-title>Colors</f7-block-title>
  57. <div class="list simple-list">
  58. <ul>
  59. <li>
  60. <f7-progressbar color="blue" :progress="10"></f7-progressbar>
  61. </li>
  62. <li>
  63. <f7-progressbar color="red" :progress="20"></f7-progressbar>
  64. </li>
  65. <li>
  66. <f7-progressbar color="pink" :progress="30"></f7-progressbar>
  67. </li>
  68. <li>
  69. <f7-progressbar color="green" :progress="80"></f7-progressbar>
  70. </li>
  71. <li>
  72. <f7-progressbar color="yellow" :progress="90"></f7-progressbar>
  73. </li>
  74. <li>
  75. <f7-progressbar color="orange" :progress="100"></f7-progressbar>
  76. </li>
  77. </ul>
  78. </div>
  79. </f7-page>
  80. </template>
  81. <script>
  82. export default {
  83. methods: {
  84. setInlineProgress(value) {
  85. const self = this;
  86. const app = self.$f7;
  87. app.progressbar.set('#demo-inline-progressbar', value);
  88. },
  89. showDeterminate(inline) {
  90. const self = this;
  91. const app = self.$f7;
  92. if (self.determinateLoading) return;
  93. self.determinateLoading = true;
  94. let progressBarEl;
  95. if (inline) {
  96. progressBarEl = app.progressbar.show('#demo-determinate-container', 0);
  97. } else {
  98. progressBarEl = app.progressbar.show(0, app.theme === 'md' ? 'yellow' : 'blue');
  99. }
  100. let progress = 0;
  101. function simulateLoading() {
  102. setTimeout(() => {
  103. const progressBefore = progress;
  104. progress += Math.random() * 20;
  105. app.progressbar.set(progressBarEl, progress);
  106. if (progressBefore < 100) {
  107. simulateLoading(); // keep "loading"
  108. } else {
  109. self.determinateLoading = false;
  110. app.progressbar.hide(progressBarEl); // hide
  111. }
  112. }, Math.random() * 200 + 200);
  113. }
  114. simulateLoading();
  115. },
  116. showInfinite(multiColor) {
  117. const self = this;
  118. const app = self.$f7;
  119. if (self.infiniteLoading) return;
  120. self.infiniteLoading = true;
  121. if (multiColor) {
  122. app.progressbar.show('multi');
  123. } else {
  124. app.progressbar.show(app.theme === 'md' ? 'yellow' : 'blue');
  125. }
  126. setTimeout(() => {
  127. self.infiniteLoading = false;
  128. app.progressbar.hide();
  129. }, 3000);
  130. },
  131. },
  132. };
  133. </script>