美文网首页
父组件获取子组件的数据和方法

父组件获取子组件的数据和方法

作者: very_cute_girls | 来源:发表于2019-12-06 14:25 被阅读0次

    #调用子组件的时候定义一个 ref

    <v-header ref="header"></v-header>
    

    #如何使用子组件数据和方法

    this.$refs.header.属性名
    or
    this.$refs.header.方法名
    

    #子组件主动获取父组件里的属性和方法

    this.$parent.属性
    or
    this.$parent.方法
    

    相关文章

      网友评论

          本文标题:父组件获取子组件的数据和方法

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