vue子组件改变父组件的值


1 在父组件的coment绑定事件

<template>
  <div :class="classObj" class="app-wrapper">
      <app-main v-on:child-say="listenToMyBoy" />
  </div>
</template>

在父组件的methods中添加

listenToMyBoy(something){
      this.childWords = something
    }

2 在子组件中改变值

this.$emit('child-say',this.loadingStatus)

另外 子组件获取父组件的值

this.$parent.childWords  //childWords为父组件的数据或者方法

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM