美文网首页
VUE3.0父子组件传递函数的方法

VUE3.0父子组件传递函数的方法

作者: 是曹不是蔡 | 来源:发表于2021-06-01 17:46 被阅读0次

父组件

 <navBar  :onClickRight="onClickRight"></navBar>

setup() {
 let onClickRight = () => {
      console.log("你好");
    };
    return {
      onClickRight,
    };

  },

子组件

<van-nav-bar  @click-right="onClickRight" />

props: {
    onClickRight: {
      type: Function,
      default: () => {
        return Function;
      },
    },
  },


setup(props, { emit, attrs, slots }) {
    let { onClickRight } = toRefs(props); // 让props下的count保持活性
  },
};


相关文章

网友评论

      本文标题:VUE3.0父子组件传递函数的方法

      本文链接:https://www.haomeiwen.com/subject/thcgsltx.html