child.uvue 1.3 KB
Newer Older
crlfe's avatar
crlfe 已提交
1 2 3 4
<template>
  <view>
    <view class="row">
      <text>hasPropsAttrs</text>
crlfe's avatar
crlfe 已提交
5
      <text class="has-props-attrs">{{ hasPropsAttrs }}</text>
crlfe's avatar
crlfe 已提交
6 7 8
    </view>
    <view class="row">
      <text>hasEmitsAttr</text>
crlfe's avatar
crlfe 已提交
9
      <text class="has-emits-attrs">{{ hasEmitsAttr }}</text>
crlfe's avatar
crlfe 已提交
10 11 12
    </view>
    <view class="row">
      <text>hasAttrs</text>
crlfe's avatar
crlfe 已提交
13
      <text class="has-attrs">{{ hasAttrs }}</text>
crlfe's avatar
crlfe 已提交
14 15 16 17
    </view>
  </view>
</template>

18
<script lang='uts'>
crlfe's avatar
crlfe 已提交
19 20 21 22 23 24 25 26 27
export default {
  emits: ['result'],
  props: {
    val: {
      type: String,
      default: "default value"
    }
  },
  computed: {
28 29
    hasPropsAttrs(): boolean {
      // #ifdef UNI-APP-X && APP-ANDROID
crlfe's avatar
crlfe 已提交
30
      return this.$attrs.has('val')
31 32 33 34 35
      // #endif
      // #ifdef UNI-APP-X && WEB
      return !!this.$attrs['val']
      // #endif

crlfe's avatar
crlfe 已提交
36 37
    },
    hasEmitsAttr (): boolean {
38
      // #ifdef UNI-APP-X && APP-ANDROID
crlfe's avatar
crlfe 已提交
39
      return this.$attrs.has('result')
40 41 42 43
      // #endif
      // #ifdef UNI-APP-X && WEB
      return !!this.$attrs['result']
      // #endif
crlfe's avatar
crlfe 已提交
44 45
    },
    hasAttrs (): boolean {
46
      // #ifdef UNI-APP-X && APP-ANDROID
crlfe's avatar
crlfe 已提交
47
      return this.$attrs.has('class')
48 49 50 51
      // #endif
      // #ifdef UNI-APP-X && WEB
      return !!this.$attrs['class']
      // #endif
crlfe's avatar
crlfe 已提交
52 53 54 55 56 57
    }
  }
}
</script>

<style scoped>
58 59 60 61 62 63
.row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin-bottom: 10px;
}
crlfe's avatar
crlfe 已提交
64
</style>