uni-ui
uni-ui copied to clipboard
[微信小程序] uni-rate 评分组件Bug
当页面有swiper时,uni-rate 评分组件不在第一屏时,如下代码中的 ret[0].left 包含了前面几屏的宽度。
例如,屏宽390,uni-rate在第二屏的60位置时,left 是450。这样造成 clientX - this._rateBoxLeft 为负值。
而,在_getRateCount方法中调用this._getSize(),获取this._rateBoxLeft的值的方式是异步的,下面使用this._rateBoxLeft的地方还是上次获取到的值。
uni.createSelectorQuery() .in(this) .select('.uni-rate') .boundingClientRect() .exec(ret => { if (ret) { this._rateBoxLeft = ret[0].left } })