Blogger Information
Blog 85
fans 0
comment 0
visits 94814
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
微信小程序官方组件展示之视图容器share-element源码
软件事业部
Original
617 people have browsed it

以下将展示微信小程序之视图容器share-element源码官方组件能力,组件样式仅供参考,开发者可根据自身需求定义组件样式,具体属性参数详见小程序开发文档。
功能描述:
共享元素。
共享元素是一种动画形式,类似于 flutter Hero动画,表现为元素像是在页面间穿越一样。该组件需与 page-container 组件结合使用。
使用时需在当前页放置 share-element 组件,同时在 page-container 容器中放置对应的 share-element 组件,对应关系通过属性值 key 映射。当设置 page-container 显示时,transform 属性为 true 的共享元素会产生动画。当前页面容器退出时,会产生返回动画。
属性说明:

示例代码:
WXML:

  1. <view>
  2. <view class="screen screen1">
  3. <block wx:for="{{contacts}}" wx:key="id" wx:for-item="contact">
  4. <view class="contact" bindtap="showNext" data-idx="{{index}}">
  5. <share-element duration="{{duration}}" class="name" key="name" transform="{{transformIdx === index}}">
  6. {{contact.name}}
  7. </share-element>
  8. <view class="list">
  9. <view>Phone: {{contact.phone}}</view>
  10. <view>Mobile: {{contact.mobile}}</view>
  11. <view>Email: {{contact.email}}</view>
  12. </view>
  13. </view>
  14. </block>
  15. </view>
  16. </view>
  17. <page-container
  18. show="{{show}}"
  19. overlay="{{overlay}}"
  20. close-on-slide-down
  21. duration="{{duration}}"
  22. position="{{position}}"
  23. bindbeforeenter="onBeforeEnter"
  24. bindenter="onEnter"
  25. bindafterenter="onAfterEnter"
  26. bindbeforeleave="onBeforeLeave"
  27. bindleave="onLeave"
  28. bindafterleave="onAfterLeave"
  29. bindclickoverlay="onClickOverlay"
  30. >
  31. <view class="screen screen2">
  32. <view class="contact">
  33. <share-element class="name" key="name" duration="{{duration}}" transform>
  34. {{contact.name}}
  35. </share-element>
  36. <button class="screen2-button" bindtap="showPrev" hidden="{{!show}}" hover-class="none">Click Me</button>
  37. </view>
  38. </view>
  39. </page-container>

WXSS:

  1. page {
  2. color: #333;
  3. background-color: #ddd;
  4. overflow: hidden;
  5. }
  6. button {
  7. border: 0 solid #0010ae;
  8. background-color: #1f2afe;
  9. color: #fff;
  10. font-size: 120%;
  11. padding: 8px 16px;
  12. outline-width: 0;
  13. -webkit-appearance: none;
  14. box-shadow: 0 8px 17px rgba(0, 0, 0, 0.2);
  15. }
  16. .screen {
  17. position: absolute;
  18. top: 0;
  19. bottom: 0;
  20. left: 0;
  21. right: 0;
  22. padding: 16px;
  23. -webkit-overflow-scrolling: touch;
  24. }
  25. .contact {
  26. position: relative;
  27. padding: 16px;
  28. background-color: #fff;
  29. width: 100%;
  30. height: 100%;
  31. box-sizing: border-box;
  32. }
  33. .avatar {
  34. position: absolute;
  35. top: 16px;
  36. left: 16px;
  37. font-size: 0;
  38. }
  39. .name {
  40. height: 65px;
  41. font-size: 2em;
  42. font-weight: bold;
  43. text-align: center;
  44. margin: 10px 0;
  45. }
  46. .list {
  47. padding-top: 8px;
  48. padding-left: 32px;
  49. }
  50. .screen1 {
  51. overflow-y: scroll;
  52. padding: 0;
  53. }
  54. .screen1 .contact {
  55. margin: 16px;
  56. height: auto;
  57. width: auto;
  58. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.2);
  59. }
  60. .screen2-button {
  61. display: block;
  62. margin: 24px auto;
  63. }
  64. .paragraph {
  65. -webkit-transition: transform ease-in-out 300ms;
  66. transition: transform ease-in-out 300ms;
  67. -webkit-transform: scale(0.6);
  68. transform: scale(0.6);
  69. }
  70. .enter.paragraph {
  71. transform: none;
  72. }

版权声明: 本站所有内容均由互联网收集整理、上传,如涉及版权问题,我们第一时间处理。
原文链接地址:
https://developers.weixin.qq.com/miniprogram/dev/component/share-element.html

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post