Comp1.uvue 880 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <view :id="compId" ref="uxToastItemRef">
  3. <text>hello</text>
  4. <slot></slot>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. compId: 'comp1-id',
  12. testNode1: false
  13. }
  14. },
  15. props: {
  16. id: {
  17. type: String,
  18. default: ''
  19. }
  20. },
  21. emits: ['ready'],
  22. mounted() {
  23. uni.createSelectorQuery().in(this).select('#comp1-id').boundingClientRect().exec((ret) => {
  24. console.log(ret)
  25. this.testNode1 = ret.length > 0
  26. // #ifdef WEB || MP
  27. this.testNode1 = this.testNode1 && ret[0] != null
  28. // #endif
  29. if(this.testNode1) {
  30. console.log('Comp1测试符合预期')
  31. } else {
  32. console.error('Comp1测试不符合预期')
  33. }
  34. this.$emit('ready', this.testNode1)
  35. })
  36. }
  37. }
  38. </script>
  39. <style>
  40. </style>