vue父组件调用子组件的方法

父组件中写法:

<div style="padding: 10px">
                    <columnTwo ref="child" style="height: 200px;" :columnDataName="columnDataName"
                               :columnData="columnData"></columnTwo>
                </div>

  

 

 父组件中赋值以及调用:

 that.columnDataName = arr1;
                        that.columnData = arr2;
                        that.$nextTick(() => {
                            that.$refs.child.$emit("childMethods")
                        })

  子组件写法:

 

        mounted() {
            this.$nextTick(()=>{
                this.$on('childMethods',function () {
                    this.echartsLine()
                })
            })
        },

  

 

posted on 2023-05-16 17:24  代码吴彦祖  阅读(147)  评论(0编辑  收藏  举报