在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 父組件傳遞數(shù)據(jù)給子組件,那么此數(shù)據(jù)在父組件中改變后,子組件會不會相應(yīng)地改變呢?

父組件傳遞數(shù)據(jù)給子組件,那么此數(shù)據(jù)在父組件中改變后,子組件會不會相應(yīng)地改變呢?

我有一個(gè)子組件,接受一個(gè)props (data),父組件傳遞給子組件。

父組件使用:

<template>
  <sub-component :data="sub_data"></sub-component>
</template>

子組件中:


export default{
  props: {
    data: {
      type: Array,
      required: true
    }
  }
}

請問下,父組件中sub_data數(shù)據(jù)得到修改之后,子組件的data會不會相應(yīng)地改變呢、

回答
編輯回答
嫑吢丕

我親自測試成功,是會改變的。

父組件:

<delete-selection-btn :selection="selection" ></delete-selection-btn>

子組件:

<script>

  export default{
    props:{
      selection: {
        type: Array,
        required: true
      }
    }
    ,
    data(){
      return {
        msg: 'hello vue'
      }
    },
    methods: {
      delete_selection_proptip_click(){
        console.log(this.selection)
      }
    }
  }
</script>    
2017年2月16日 18:15