本篇文章給大家分享的是有關怎么在微信小程序中實現一個點擊卡片翻轉效果,小編覺得挺實用的,因此分享給大家學習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業的熱愛。我們立志把好的技術通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領域值得信任、有價值的長期合作伙伴,公司提供的服務項目有:主機域名、雅安服務器托管、營銷軟件、網站建設、郴州網站維護、網站推廣。
wxml:
<view class='main'> <!--正面的框 --> <view class="box b1" animation="{{animationMain}}" bindtap='rotateFn' data-id="1" > <image src=""></image> </view> <!--背面的框 --> <view class="box b2" animation="{{animationBack}}" bindtap='rotateFn' data-id="2"> <image src=""></image> </view> </view>
wxss:
.main { position: absolute; top: 50%; left: 50%; width: 300px; height: 300px; transform: translate(-50%,-50%); -webkit-perspective: 1500;//子元素獲得透視效果 -moz-perspective: 1500; } .box { position: absolute; top: 0; left: 0; width: 300px; height: 300px; transition: all 1s; backface-visibility: hidden; border-radius: 10px; cursor: pointer; } .box image{ border-radius: 10px; width: 100%; height: 100%; } .b1{ background:skyblue; } .b2 { background:tomato; transform: rotateY(-180deg); } js: Page({ data: { animationMain:null,//正面 animationBack:null,//背面 }, rotateFn(e) { var id = e.currentTarget.dataset.id this.animation_main = wx.createAnimation({ duration:400, timingFunction:'linear' }) this.animation_back = wx.createAnimation({ duration:400, timingFunction:'linear' }) // 點擊正面 if (id==1) { this.animation_main.rotateY(180).step() this.animation_back.rotateY(0).step() this.setData({ animationMain: this.animation_main.export(), animationBack: this.animation_back.export(), }) } // 點擊背面 else{ this.animation_main.rotateY(0).step() this.animation_back.rotateY(-180).step() this.setData({ animationMain: this.animation_main.export(), animationBack: this.animation_back.export(), }) } }, })
以上就是怎么在微信小程序中實現一個點擊卡片翻轉效果,小編相信有部分知識點可能是我們日常工作會見到或用到的。希望你能通過這篇文章學到更多知識。更多詳情敬請關注創新互聯行業資訊頻道。
網頁標題:怎么在微信小程序中實現一個點擊卡片翻轉效果
網站地址:http://vcdvsql.cn/article4/gjssie.html
成都網站建設公司_創新互聯,為您提供外貿網站建設、關鍵詞優化、微信小程序、搜索引擎優化、商城網站、電子商務
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯