学无先后,达者为师

网站首页 编程语言 正文

:prop父组件给子组件传递函数 子组件接收 并default子组件自己的方法 问题

作者:接着奏乐接着舞 更新时间: 2023-08-15 编程语言

default: 中取不到this

props:{
    beforeClose: {
      type: Function,
      default: null,
    },
}

判断子组件是否接到父组件的方法 接到使用 没有接到进else自定义方法

beforeClose1() {
  console.log(this.beforeClose);
  console.log(5555);
  if (this.beforeClose) {
    return this.beforeClose();
  } else {
  }
},
:before-close="beforeClose1"

原文链接:https://blog.csdn.net/a378113472/article/details/123942950

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新