vue3父传子

1.father.vue

<template>
   <div>
      <Son :data=name></Son> 
   </div>
</template>
<script>
import Son from './son'
export default {
   components:{
      Son
   },
   setup() {
      const name = '小范'
      return{
         name
      } 
   }
}
</script>

2.son.vue

<template>
   <div>
    {{data}}
   </div>
</template>
<script>

export default {
   props:['data'],
   setup(props,context) {
      console.log(props)
      console.log(context)
      console.log(props.data,'father text')
      return{  
      }
   }
}
</script>

setup的两个参数.props接收 context传出

上一篇:[2021 Spring] CS61B 学习笔记 Lab 1 Setup: Setting Up Your Computer


下一篇:filebate安装读取nginx json日志