经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 移动开发 » 微信小程序 » 查看文章
微信小程序实现点击图片旋转180度并且弹出下拉列表
来源:jb51  时间:2018/11/28 9:30:56  对本文有异议

本文为大家分享了微信小程序实现图片旋转、下拉列表的具体代码,供大家参考,具体内容如下

正文:

先上效果图:

index.wxml

  1. <view class="phone_one" bindtap="clickPerson">
  2. <view class="phone_personal">{{firstPerson}}</view>
  3. <image src="../../image/v6.png" class="personal_image {{selectArea ? 'rotateRight' :''}}"></image> //三目法判断图片要不要旋转180。
  4. </view>
  5. <view class="person_box">
  6. <view class="phone_select" hidden="{{selectPerson}}">
  7. <view bindtap="mySelect">测试1</view>
  8. <view bindtap="mySelect">测试2</view>
  9. <view bindtap="mySelect">测试3</view>
  10. </view>
  11. </view>

index.js

  1. Page({
  2. data:{
  3. selectPerson:true,
  4. firstPerson:'个人',
  5. selectArea:false,
  6. },
  7. //点击选择类型
  8. clickPerson:function(){
  9. var selectPerson = this.data.selectPerson;
  10. if(selectPerson == true){
  11. this.setData({
  12. selectArea:true,
  13. selectPerson:false,
  14. })
  15. }else{
  16. this.setData({
  17. selectArea:false,
  18. selectPerson:true,
  19. })
  20. }
  21. } ,
  22. //点击切换
  23. mySelect:function(e){
  24. this.setData({
  25. firstPerson:e.target.dataset.me,
  26. selectPerson:true,
  27. selectArea:false,
  28. })
  29. },
  30. }}

index.wxss

  1. .phone_personal{
  2. width: 100%;
  3. color:rgb(34, 154, 181);
  4. height:100rpx;
  5. line-height:100rpx;
  6. text-align: center;
  7. }
  8. .phone_one{
  9. display: flex; //用flex布局更方便。
  10. position: relative;
  11. justify-content: space-between;
  12. background-color:rgb(239, 239, 239);
  13. width:90%;
  14. height:100rpx;
  15. margin:0 auto;
  16. border-radius: 10rpx;
  17. border-bottom:2rpx solid rgb(255, 255, 255);
  18. }
  19. .person_box{
  20. position: relative;
  21. }
  22. .phone_select{
  23. margin-top:0;
  24. z-index: 100;
  25. position: absolute; //小程序中z-index和absolute需要同时存在,元素才能脱离文档。
  26. }
  27. .select_one{
  28. text-align: center;
  29. background-color:rgb(239, 239, 239);
  30. width:676rpx; //脱离文档后元素width不能再用百分比。
  31. height:100rpx;
  32. line-height:100rpx;
  33. margin:0 5%;
  34. border-bottom:2rpx solid rgb(255, 255, 255);
  35. }
  36. .personal_image{
  37. z-index: 100;
  38. position: absolute;
  39. right:2.5%;
  40. width: 34rpx;
  41. height: 20rpx;
  42. margin:40rpx 20rpx 40rpx 0;
  43. transition: All 0.4s ease;
  44. -webkit-transition: All 0.4s ease;
  45. }
  46. .rotateRight{
  47. transform: rotate(180deg); //180°旋转图片。
  48. }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持w3xue。

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号