tree: 2dbaca168ae21a48ee198c6c5dfd9370d0329378 [path history] [tgz]
  1. index.js
  2. index.vue
  3. package.json
  4. README.md
  5. README_cn.md
packages/wxc-progress/README.md

wxc-progress

Display the current progress of an operation flow.

Rule

  • When you need to display the completion percentage of an operation.
  • You need to tell the current progress accurately, or you should use Loading

Demo

    

Code Example

<template>
  <div class="wrapper">
    <div class="demo">
      <text class="demo-text">default</text>
      <wxc-progress></wxc-progress>
    </div>
    <div class="demo">
      <text class="demo-text">set value</text>
      <wxc-progress :value=50 :bar-width=600></wxc-progress>
    </div>
    <div class="demo">
      <text class="demo-text">custom</text>
      <wxc-progress :value=70
                    bar-color='#9B7B56'
                    :bar-height=16
                    :bar-radius=16
                    :bar-width=640></wxc-progress>
    </div>
    <div class="btn" @click="uploadFile">
      <text class="btn-txt">upload files</text>
    </div>
    <div class="up-demo" v-if="progressVisible">
      <text class="progress-text left">0%</text>
      <wxc-progress :value="value" :bar-width=540></wxc-progress>
      <text class="progress-text right">{{value}}%</text>
    </div>
  </div>
</template>

<script>
  import { WxcProgress } from 'weex-ui'
  export default {
    components: { WxcProgress },
    data: () => ({
      value: 0,
      uploading: false,
      progressVisible: false,
      timer: null
    }),
    methods: {
      uploadFile () {
        if (!this.uploading) {
          this.value = 0;
          this.uploading = true;
          this.progressVisible = true;
          this.timer = setInterval(() => {
            if (this.value < 100) {
              this.value++
            } else {
              this.uploading = false;
              setTimeout(() => {
                this.progressVisible = false;
              }, 500)
              clearTimeout(this.timer);
            }
          }, 10);
        }
      }
    }
  }
</script>

More details can be found in here

API

PropTypeRequiredDefaultDescription
valueNumberY0percent (0-100)
bar-heightNumberN8progress bar height
bar-colorStringN#FFC900progress bar color
bar-widthNumberN600progress bar width
bar-radiusnumbern0progress bar radius
background-colorStringN#f2f3f4overall background color