Tag:vue.jsjavascript
Article From:https://segmentfault.com/q/1010000012151940
Question:

The prop I received in the subcomponent is
props:{
data1:{
type:Array,
default:[],
}
}

Why is mounted printing in sub components empty? The length is 0

Answer 0:

The code is too little to judge.

First, confirm the parent componentdata1Is there any value

Second, subcomponentspropsThe default value of array / object should be returned by a factory function, such as:

props:{
    data1:{
        type:Array,
        default: function() {
            return []
        }
    }
}

Similar Posts:

Link of this Article: Vue one-way data stream

Leave a Reply

Your email address will not be published. Required fields are marked *