wxc-progress

Weex 进度条组件

规则

  • 表明某个任务的当前进度
  • 需要准确告知当前进度,否则应该使用 Loading

Demo

wxc-progress 进度条 - 图1 wxc-progress 进度条 - 图2

使用方法

  1. <template>
  2. <div class="wrapper">
  3. <div class="demo">
  4. <text class="demo-text">默认</text>
  5. <wxc-progress></wxc-progress>
  6. </div>
  7. <div class="demo">
  8. <text class="demo-text">设置value</text>
  9. <wxc-progress :value=50 :bar-width=600></wxc-progress>
  10. </div>
  11. <div class="demo">
  12. <text class="demo-text">自定义</text>
  13. <wxc-progress :value=70
  14. bar-color='#9B7B56'
  15. :bar-height=16
  16. :bar-radius=16
  17. :bar-width=640></wxc-progress>
  18. </div>
  19. <div class="btn" @click="uploadFile">
  20. <text class="btn-txt">上传文件</text>
  21. </div>
  22. <div class="up-demo" v-if="progressVisible">
  23. <text class="progress-text left">0%</text>
  24. <wxc-progress :value="value" :bar-width=540></wxc-progress>
  25. <text class="progress-text right">{{value}}%</text>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { WxcProgress } from 'weex-ui'
  31. export default {
  32. components: { WxcProgress },
  33. data: () => ({
  34. value: 0,
  35. uploading: false,
  36. progressVisible: false,
  37. timer: null
  38. }),
  39. methods: {
  40. uploadFile () {
  41. if (!this.uploading) {
  42. this.value = 0;
  43. this.uploading = true;
  44. this.progressVisible = true;
  45. this.timer = setInterval(() => {
  46. if (this.value < 100) {
  47. this.value++
  48. } else {
  49. this.uploading = false;
  50. setTimeout(() => {
  51. this.progressVisible = false;
  52. }, 500)
  53. clearTimeout(this.timer);
  54. }
  55. }, 10);
  56. }
  57. }
  58. }
  59. }
  60. </script>

更详细代码可以参考 demo

可配置参数

Prop Type Required Default Description
value Number Y 0 百分比(0-100)
bar-height Number N 8 高度
bar-width Number N 600 长度
bar-color String N #FFC900 颜色
bar-radius Number N 0 圆角

Please feel free to use and contribute to the development.

原文: https://alibaba.github.io/weex-ui/#/cn/packages/wxc-progress/