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