父组件向子组件传值
父亲代码
<detail-bar :num='carNum'></detail-bar>
孩子代码
<view class="cart_tag">{{num}}</view>
script中
props: {
num: {
type: Number,
default:0
}
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
子组件向父组件传值
孩子代码
页面
<input @input="getValue">
js
getValue(e){
let value = e.detail.value
this.$emit('value',value)
}
父亲代码
页面
<uni-number-box :min="1" :max="9" @change='childChange'></uni-number-box>
js
childChange(e){
this.count = e
},