methods:{
// 判断左右侧高
judgmentH(){
Promise.all([
new Promise((success, fail)=>{
wx.createSelectorQuery().in(this).select('.left').boundingClientRect().exec(function (res) {
leftHeight = res[0].height;
success()
})
}),
new Promise((success, fail)=>{
wx.createSelectorQuery().in(this).select('.right').boundingClientRect().exec(function (res) {
rightHeight = res[0].height;
success()
})
}),
]).then(success=>{
leftHeight - rightHeight <= 0 ? count = true : count = false;
return count
})
},
// 添加数据
add(){
console.log(this.judgmentH()) // => true / false
}
如上图,我想在 调用judgmentH 函数的时候拿到一个布尔
值
这个布尔
值在Promise.all中的.then()返回