最近想做个进度条,发现百度到的结果和自己要的不一样,于是结合https://ext.dcloud.net.cn/plugin?id=1339源代码做了一个简单的进度条,代码如下:
1 <template> 2 <view class="page" > 3 <movable-area class="zoom"> 4 <movable-view x="100" direction="all" inertia="true" class="ball" @click="useCamera" @touchmove='getInfo' ></movable-view> 5 </movable-area> 6 <view class="" >{{position}}</view> 7 </view> 8 </template> 9 10 <script> 11 export default { 12 data() { 13 return { 14 position:'' 15 } 16 }, 17 mounted() { 18 this.getInfo() 19 }, 20 methods: { 21 getInfo:function(){ 22 const query = uni.createSelectorQuery().in(this); 23 query.select('.ball').boundingClientRect(data => { 24 var result = (data.left-47)/124*50 25 this.position = parseInt(result) 26 }).exec(); 27 } 28 } 29 } 30 </script> 31 32 <style> 33 .page { 34 display: flex; 35 flex-direction: row; 36 } 37 38 .zoom { 39 width: 560rpx; 40 height: 64rpx; 41 margin-left: 95rpx; 42 background-color: #007AFF; 43 border-radius: 64rpx; 44 } 45 .ball { 46 width: 64rpx; 47 height: 64rpx; 48 border-radius: 100%; 49 background-color: #00FFFF; 50 } 51 </style>