根组件:
<script> import { provide } from 'vue' export default { setup(){ provide('name','xiaoming') } </script>
后代组件:
<script> import { inject } from 'vue' export default { setup(){ let myName= inject('name') console.log(myName) //xiaoming } } </script>