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

以下将展示微信小程序之视图容器movable-area官方组件能力,组件样式仅供参考,开发者可根据自身需求定义组件样式,具体属性参数详见小程序开发文档。
功能描述:
movable-view的可移动区域。
属性说明:

Bug & Tip
1.tip: movable-area 必须设置 width 和height属性,不设置默认为10px**
2.tip: 当 movable-view 小于 movable-area 时,movable-view的移动范围是在 movable-area 内;
3.tip: 当 movable-view 大于 movable-area 时,movable-view的移动范围必须包含movable-area(x轴方向和 y 轴方向分开考虑)
4.tip: 若当前组件所在的页面或全局开启了 enablePassiveEvent 配置项,该内置组件可能会出现非预期表现(详情参考 enablePassiveEvent 文档)

示例代码
JAVASCRIPT

  1. Page({
  2. onShareAppMessage() {
  3. return {
  4. title: 'movable-view',
  5. path: 'page/component/pages/movable-view/movable-view'
  6. }
  7. },
  8. data: {
  9. x: 0,
  10. y: 0,
  11. scale: 2,
  12. },
  13. tap() {
  14. this.setData({
  15. x: 30,
  16. y: 30
  17. })
  18. },
  19. tap2() {
  20. this.setData({
  21. scale: 3
  22. })
  23. },
  24. onChange(e) {
  25. console.log(e.detail)
  26. },
  27. onScale(e) {
  28. console.log(e.detail)
  29. }
  30. })

WXML:

  1. <view class="container">
  2. <view class="page-body">
  3. <view class="page-section">
  4. <view class="page-section-title first">movable-view区域小于movable-area</view>
  5. <movable-area>
  6. <movable-view x="{{x}}" y="{{y}}" direction="all">text</movable-view>
  7. </movable-area>
  8. </view>
  9. <view class="btn-area">
  10. <button bindtap="tap" class="page-body-button" type="primary">点击移动到 (30px, 30px)</button>
  11. </view>
  12. <view class="page-section">
  13. <view class="page-section-title">movable-view区域大于movable-area</view>
  14. <movable-area>
  15. <movable-view class="max" direction="all">text</movable-view>
  16. </movable-area>
  17. </view>
  18. <view class="page-section">
  19. <view class="page-section-title">只可以横向移动</view>
  20. <movable-area>
  21. <movable-view direction="horizontal">text</movable-view>
  22. </movable-area>
  23. </view>
  24. <view class="page-section">
  25. <view class="page-section-title">只可以纵向移动</view>
  26. <movable-area>
  27. <movable-view direction="vertical">text</movable-view>
  28. </movable-area>
  29. </view>
  30. <view class="page-section">
  31. <view class="page-section-title">可超出边界</view>
  32. <movable-area>
  33. <movable-view direction="all" out-of-bounds>text</movable-view>
  34. </movable-area>
  35. </view>
  36. <view class="page-section">
  37. <view class="page-section-title">带有惯性</view>
  38. <movable-area>
  39. <movable-view direction="all" inertia>text</movable-view>
  40. </movable-area>
  41. </view>
  42. <view class="page-section">
  43. <view class="page-section-title">可放缩</view>
  44. <movable-area scale-area>
  45. <movable-view direction="all" bindchange="onChange" bindscale="onScale" scale scale-min="0.5" scale-max="4" scale-value="{{scale}}">text</movable-view>
  46. </movable-area>
  47. </view>
  48. <view class="btn-area">
  49. <button bindtap="tap2" class="page-body-button" type="primary">点击放大3倍</button>
  50. </view>
  51. </view>
  52. </view>

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