define-emits.uvue 1.6 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
  <!-- #ifdef APP -->
  <scroll-view style="flex: 1">
  <!-- #endif -->
    <view class="page">
      <ArrayLiteral @change='handleArrayLiteralCompChange' />
      <text id="handle-array-literal-change-res" class="uni-common-mt">handle array literal comp change result:
        {{handleArrayLiteralCompChangeRes}}</text>
      <TypeEmits1 @change='handleTypeEmits1CompChange' />
      <text id="handle-type-emits1-change-res" class="uni-common-mt">handle type emits comp change result:
        {{handleTypeEmits1CompChangeRes}}</text>
      <TypeEmits2 @change='handleTypeEmits2CompChange' />
      <text id="handle-type-emits2-change-res" class="uni-common-mt">handle type emits named tuple syntax comp change
        result: {{handleTypeEmits2CompChangeRes}}</text>
    </view>
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
DCloud-WZF's avatar
DCloud-WZF 已提交
19 20
</template>

DCloud-WZF's avatar
DCloud-WZF 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
<script setup>
  import ArrayLiteral from './array-literal.uvue';
  import TypeEmits1 from './type-emits-1.uvue';
  import TypeEmits2 from './type-emits-2.uvue';

  const handleArrayLiteralCompChangeRes = ref('')
  const handleArrayLiteralCompChange = (num : number) => {
    handleArrayLiteralCompChangeRes.value = `options is ${num}`
  }

  const handleTypeEmits1CompChangeRes = ref('')
  const handleTypeEmits1CompChange = (num : number) => {
    handleTypeEmits1CompChangeRes.value = `options is ${num}`
  }

  const handleTypeEmits2CompChangeRes = ref('')
  const handleTypeEmits2CompChange = (num : number) => {
    handleTypeEmits2CompChangeRes.value = `options is ${num}`
  }
</script>