VUE3父子传值

1.子传父

1.

 <SlotsOne

        @changeUser="changeUser"

        @changeBtn="changeBtn"

      ></SlotsOne>

在父组件对子组件调用位置写上传递方法名称

2.子组件之中setup(props, ctx)

3.子组件之中

 return {

      ...toRefs(state),

      ctx,

    };

4.子组件之中 ctx.emit("changeUser");

如果有传值的话跟vue2一样直接写在方法后面就行ctx.emit("changeUser",true)

猜你喜欢

转载自blog.csdn.net/weixin_51263829/article/details/128036593