自定义组件文档上有写可以指定属性类型为“Function”,试了一下,貌似没有用,app.json 已指定"component2": true 代码如下:
组件代码:
Component({
properties: {
test: {
type: Function,
observer: (val) => {
console.log(val); // 打印为null
}
}
},
ready(){
console.log(this.data.test); // 打印为null
},
methods:{
}
});页面代码:
<service test="{{showPopup}}" />
Page({
data: {
showPopup() {
this.setData({
popupShow: true,
});
},
},
},
onShow(){
this.setData({
showDialog: ()=> {
console.log(123);
}
})
},
showDialog() {
this.setData({
dialogShow: true,
});
},
showPopup() {
this.setData({
popupShow: true,
});
},
});文档上也没个示例说该怎么弄,还请解答一下困惑,万分感谢!!!
