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为父组件的数据或者方法

猜你喜欢

转载自www.cnblogs.com/huge1122/p/11424224.html