define-model.uvue 874 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4 5 6
  <view class="page">
    <Foo v-model='str' v-model:msg="msg" @update:modelValue="handleModelValueUpdate" @update:msg="handleMsgUpdate" />
    <input class='uni-common-mt input' id="model-value-input" v-model="str" />
    <input class='uni-common-mt input' id="msg-input" v-model="msg" />
  </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
7 8
</template>

DCloud-WZF's avatar
DCloud-WZF 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<script setup>
  import Foo from './Foo.uvue'

  const str = ref('str')
  const msg = ref('msg')

  const handleModelValueUpdateRes = ref('')
  const handleModelValueUpdate = (val : string) => {
    handleModelValueUpdateRes.value = `new str value: ${val}`
  }
  const handleMsgUpdateRes = ref('')
  const handleMsgUpdate = (val : string) => {
    handleMsgUpdateRes.value = `new msg value: ${val}`
  }
</script>

<style>
  .input {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
  }
</style>