zoukankan      html  css  js  c++  java
  • vue父组件获取子组件的数据

    1.写子组件时候在子组件上写上ref属性

    <child-first ref="first" ></child-first>

    2.调用子组件的方法或者data

    //调用方法  还能获取返回值 
    let childData = this.$refs.first.getData();
    
    //直接获取子组件的值
    console.log(this.$refs.first.res)

    注意:这个“first”是唯一标识 上下要一致

  • 相关阅读:
    SQL注入
    浅复制
    重构
    UML
    UML
    工业4.0
    MVC
    博客搬家(CSDN->博客园)
    BitCoin
    Java
  • 原文地址:https://www.cnblogs.com/rainbowLover/p/12068508.html
Copyright © 2011-2022 走看看