Properties props method defined vue

When the sub-assembly receives the value of the parent component pass over, we generally have two ways to receive

But everyone seems to have a second way, I only uncertain data type when it is used first approach

The first:

Export default {
     // do not detect the type, accept it 
    The props: [ "CUSTOMER_ID" ], 
}

 

The second:

. 1 Export default {
 2    The props: {
 . 3      // base type detector ( `null` means may be of any type) 
. 4      propA: null ,
 . 5      // plurality of types 
. 6      propB,: [String, Number The],
 . 7      // will pass and string 
. 8      propC: {
 . 9        type: string,
 10        required: to true 
. 11      },
 12 is      // figures, have default values 
13 is      propD: {
 14        type: number The,
 15        default : 100
 16      },
 . 17      //The default value of the array / object should be returned by a function of plant 
18 is      PROPE: {
 . 19        type: Object,
 20 is        default : function () {
 21 is          return {Message: 'Hello' }
 22 is        }
 23 is      },
 24      // custom validation function 
25      propF: {
 26 is        Validator: function (value) {
 27          return value> 10
 28        }
 29      }
 30    }
 31 is }

 

Guess you like

Origin www.cnblogs.com/jun-qi/p/10931641.html