微信小程序实现点击图片旋转180度并且弹出下拉列表 - 新闻资讯 - 云南小程序开发|云南软件开发|云南网站建设-昆明葵宇信息科技有限公司

159-8711-8523

云南网建设/小程序开发/软件开发

知识

不管是网站,软件还是小程序,都要直接或间接能为您产生价值,我们在追求其视觉表现的同时,更侧重于功能的便捷,营销的便利,运营的高效,让网站成为营销工具,让软件能切实提升企业内部管理水平和效率。优秀的程序为后期升级提供便捷的支持!

您当前位置>首页 » 新闻资讯 » 小程序相关 >

微信小程序实现点击图片旋转180度并且弹出下拉列表

发表时间:2021-4-30

发布人:葵宇科技

浏览次数:105


//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. <pre name="code" class="html">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. }}</pre><pre name="code" class="html"></pre>//index.wxss
  31. [html] view plain copy
  32. <pre name="code" class="html">.phone_personal{
  33. width: 100%;
  34. color:rgb(34, 154, 181);
  35. height:100rpx;
  36. line-height:100rpx;
  37. text-align: center;
  38. }
  39. .phone_one{
  40. display: flex; //用flex布局更方便。
  41. position: relative;
  42. justify-content: space-between;
  43. background-color:rgb(239, 239, 239);
  44. width:90%;
  45. height:100rpx;
  46. margin:0 auto;
  47. border-radius: 10rpx;
  48. border-bottom:2rpx solid rgb(255, 255, 255);
  49. }
  50. .person_box{
  51. position: relative;
  52. }
  53. .phone_select{
  54. margin-top:0;
  55. z-index: 100;
  56. position: absolute; //小程序中z-index和absolute需要同时存在,元素才能脱离文档。
  57. }
  58. .select_one{
  59. text-align: center;
  60. background-color:rgb(239, 239, 239);
  61. width:676rpx; //脱离文档后元素width不能再用百分比。
  62. height:100rpx;
  63. line-height:100rpx;
  64. margin:0 5%;
  65. border-bottom:2rpx solid rgb(255, 255, 255);
  66. }
  67. .personal_image{
  68. z-index: 100;
  69. position: absolute;
  70. right:2.5%;
  71. width: 34rpx;
  72. height: 20rpx;
  73. margin:40rpx 20rpx 40rpx 0;
  74. transition: All 0.4s ease;
  75. -webkit-transition: All 0.4s ease;
  76. }
  77. .rotateRight{
  78. transform: rotate(180deg); //180°旋转图片。
  79. }</pre>
  80. <p></p><pre name="code" class="html" style="font-size: 13.3333px;"></pre><p></p>
  81. <pre></pre>

相关案例查看更多