用于组件
props: ['title', 'likes', 'isPublished', 'commentIds', 'author']
说明这个组件有'title', 'likes', 'isPublished...', 'commentIds', 'author'这几个attribute
以下说明组件有title,likes等等属性,并且指定对应属性的类型,当给到错误类型的值时控制台会报错
props: {...title: String,
likes: Number,
isPublished: Boolean,
commentIds: Array,
author: Object,
callback...Array
Object
Date
Function
Symbol
props定义的一些情况
Vue.component('my-component', {
props: {
// 基础的类型检查...(`null` 和 `undefined` 会通过任何类型验证)
propA: Number,
// 多个可能的类型
propB: [String, Number],