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

鍍金池/ 問答/HTML/ vue 單向數(shù)據(jù)流

vue 單向數(shù)據(jù)流

我在子組件接收的prop為
props:{
data1:{
type:Array,
default:[],
}
}

在子組件的mounted 打印為什么是空呢? 長度為 0

回答
編輯回答
乖乖瀦

代碼貼的太少了,不好判斷

首先,確認(rèn)父組件里data1是否有值

其次,子組件props這種寫法不對哈,數(shù)組/對象的默認(rèn)值應(yīng)當(dāng)由一個工廠函數(shù)返回,如:

props:{
    data1:{
        type:Array,
        default: function() {
            return []
        }
    }
}
2017年12月27日 05:57