Vue父组件获取子组件数据

1、子组件addindex.vue写一个方法,返回要用的数据

methods: {
    // 父组件获取数据
    getVal () {
      return this.procedure
    }
}

2、在父组aindex.vue件中获取值

<ProcedureEdit ref="procedureEdit"></ProcedureEdit>
import ProcedureEdit from 'pages/procedure/add/addindex'
methods: {
    handleEdit () {
        let oldProcedure = this.$refs['procedureEdit'].getVal();
        console.log(oldProcedure)
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_41996632/article/details/89680953