vue 父组件修改子组件

<template>       <div class="action-group">

            <el-button size="small" @click="changeTest">自定义</el-button>
          </div>  

 <div>
  <self-column ref="self-column" ></self-column>
</div>
</template>

//局部注册组件
  import selfColumn from '@/components/column/self-column'

export default {
components: { 'self-column': selfColumn, }, 

methods:{
    changeTest() {
//父组件修改子组件的show值
    this.$refs['self-column'].show = true;
    //调用子组件中的方法loadInitData
this.$refs['self-column'].loadInitData(); }, },
}

父组件页面上使用
<self-column ref="self-column" ></self-column> 渲染子组件的页面,在方法中使用 this.$refs['self-column'].show = true; this.$refs['self-column'].loadInitData(); 可以调用子组件的值和方法

 

 

转载于:https://www.cnblogs.com/GGboy-wu/p/10481457.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值