uniapp利用movable-area制作可滑動進度條


 最近想做個進度條,發現百度到的結果和自己要的不一樣,於是結合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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM