Vue.component('child',{
props:['message'],
template:'<span>{{ message }}</span>'
})
<child message="hello!"></child>
//camelCase
Vue.component('child',{
props:['myMessage'],
template:'<span>{{ message }}</span>'
})
//kebab-case <child my-message="hello!"></child>
<div> <input v-model="parrentMsg"> <br> <child v-bind:my-message="parrentMsg"></child> </div>
<child :my-message="parrentMsg"></child>
“`
props: [‘initialCounter'],
data: function () {
return { counter: this.initialCounter}
}
```
props: ['size'],
computed: {
normalizedSize: function () {
return this.size.trim().toLowerCase()
}
}
Vue.component('example', {
props: {
// 基础类型检测 (`null` 意思是任何类型都可以)
propA: Number,
// 多种类型
propB: [String, Number],
// 必传且是字符串
propC: {
type: String,
required: true
},
// 数字,有默认值
propD: {
type: Number,
default: 100
},
// 数组/对象的默认值应当由一个工厂函数返回
propE: {
type: Object,
default: function () {
return { message: 'hello' }
}
},
// 自定义验证函数
propF: {
validator: function (value) {
return value > 10
}
}
}
})
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有