開始:
父級:index
<view class="index">
<footer phoneOptions='{{phoneOptions}}' downObj="{{downObj}}" hide="{{hideBjData}}"></footer>
</view>
onShareAppMessage: function (res) {
if (res.from === 'button') {
// 來自頁面內轉發按鈕
}
this.setData({ //在轉發時改變參數,然後組件執行 _onRefresh方法
hideBjData: {
'isshowBJ': false,
'screeningNo': 2
}
})
return {
title: '您好,我是選址顧問' + this.data.cardData.name
}
},
組件:footer 這裏只展示更改hide的值
properties: {
hide:{
type:Object,
value: {},
observer: '_onRefresh' //此值改變的函數
}
},
methods: {
_onRefresh(newVal, oldVal){ //這裏只要父級值改變,就會執行
const _this = this;
this.setData({
'isshowBJ': newVal.isshowBJ,
'screeningNo': newVal.screeningNo
})
}
}