SelectorQuery.exec

解释: 执行所有的请求,请求结果按请求次序构成数组,在 callback 的第一个参数中返回。

方法参数

Function callback

示例

在开发者工具中预览效果

扫码体验

SelectorQuery.exec - 图1请使用百度APP扫码

图片示例

SelectorQuery.exec - 图2

SelectorQuery.exec - 图3

SelectorQuery.exec - 图4

代码示例

  1. <view class="wrap">
  2. <view class="card-area">
  3. <movable-area>
  4. <movable-view class="target" x="{{x}}" y="{{y}}" direction="all" bindchange="queryNodeInfo">
  5. Drag
  6. </movable-view>
  7. </movable-area>
  8. </view>
  9. <button type="primary" bindtap="queryNodeInfo">获取Drag的exec的返回值</button>
  10. </view>
  1. Page({
  2. queryNodeInfo: function(){
  3. swan.createSelectorQuery().select('.target').boundingClientRect().exec(function(rect){
  4. console.log(rect);
  5. swan.showModal({
  6. title: 'SelectorQuery.exec的返回值',
  7. content: JSON.stringify(rect)
  8. });
  9. })
  10. }
  11. });
  1. movable-view {
  2. display: flex;
  3. align-items: center;
  4. justify-content: center;
  5. height: 100rpx;
  6. width: 100rpx;
  7. background: #38f;
  8. color: #fff;
  9. }
  10. movable-area {
  11. height: 400rpx;
  12. width: 400rpx;
  13. background-color: #ccc;
  14. overflow: hidden;
  15. }