selector-query-child-multi.uvue 1.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<template>
  <view class="selector-query-view">
    <text>selector-query</text>
    <text class="text red">{{text1}}</text>
  </view>
  <view class="selector-query-view">
    <text>selector-query</text>
    <text class="text green">{{text2}}</text>
  </view>
  <view v-if="text1.length>0">1</view>
  <text>{{text3}}</text>
</template>

<script>
  export default {
    data() {
      return {
        text1: "",
        text2: "",
DCloud-WZF's avatar
DCloud-WZF 已提交
20 21 22
        text3: "test-text-node",
        viewCount: 0,
        selectCount: 0,
23 24 25 26 27 28
        selectAllCount: 0,
        show: false
      }
    },
    mounted() {
      uni.createSelectorQuery().in(this).select('.selector-query-view').boundingClientRect().exec((ret) => {
DCloud-WZF's avatar
DCloud-WZF 已提交
29 30 31 32 33 34 35 36 37
        this.text1 = JSON.stringify(ret, null, 2)
        if (ret.length == 1) {
          this.selectCount = ret.length
        }
      })
      uni.createSelectorQuery().in(this).selectAll('.selector-query-view').boundingClientRect().exec((ret) => {
        this.text2 = JSON.stringify(ret, null, 2)
        if (ret.length == 1) {
          this.selectAllCount = (ret[0] as NodeInfo[]).length
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
        }
      })
    }
  }
</script>

<style>
  .green {
    border: 3px solid green;
  }

  .red {
    border: 3px solid red;
  }

  .view {
    border: 3px dashed lime;
    padding: 10px;
  }

  .text {
    margin-top: 20px;
    padding: 5px;
  }
</style>