vu3中的父子组件通讯

一、传统的props

通过在父组件中给子组件传值,然后在子组件中通过props接受数据

 1 //父组件
 2 <ValidateInput
 3      type="text"
 4      v-model="emailVal"
 5      :rules='emailRules'
 6      placeholder='请输入邮箱地址'
 7      ref="inputRef"
 8 >
 9 </ValidateInput>
10                     
11 //子组件
12 export default defineComponent({
13   name: 'ValidateInput',
14   props: {
15     rules: Array as PropType <RulesProp>,
16     modelValue: String
17   },
18 }
未经允许不得转载:国外主机测评 - 国外VPS,国外服务器,国外云服务器,测评及优惠码 » vu3中的父子组件通讯