Sanakey
2021-01-31 53cc6f817625897935fb10c3845ad7be400f3036
提交 | 用户 | age
d98d05 1 import { VantComponent } from '../common/component';
S 2 import { BLUE } from '../common/color';
53cc6f 3 import { getRect } from '../common/utils';
d98d05 4 VantComponent({
S 5   props: {
6     inactive: Boolean,
53cc6f 7     percentage: {
S 8       type: Number,
9       observer: 'setLeft',
10     },
d98d05 11     pivotText: String,
S 12     pivotColor: String,
13     trackColor: String,
14     showPivot: {
15       type: Boolean,
16       value: true,
17     },
18     color: {
19       type: String,
20       value: BLUE,
21     },
22     textColor: {
23       type: String,
24       value: '#fff',
25     },
26     strokeWidth: {
27       type: null,
28       value: 4,
29     },
30   },
53cc6f 31   data: {
S 32     right: 0,
33   },
34   mounted() {
35     this.setLeft();
36   },
37   methods: {
38     setLeft() {
39       Promise.all([
40         getRect(this, '.van-progress'),
41         getRect(this, '.van-progress__pivot'),
42       ]).then(([portion, pivot]) => {
43         if (portion && pivot) {
44           this.setData({
45             right: (pivot.width * (this.data.percentage - 100)) / 100,
46           });
47         }
48       });
49     },
50   },
d98d05 51 });