uView2.0 icon indicating copy to clipboard operation
uView2.0 copied to clipboard

rate min设置成1, 选择的时候会出现null

Open yourVictor opened this issue 2 years ago • 2 comments

版本

2.0.33

转载链接

new-issue.uviewui.com/

重现步骤

微信小程序: 点击第一颗和第二颗中间的空白位置会出现,不是必现,但是经常出现

期望的结果是什么?

希望可以选 >= min

实际的结果是什么?

可选小于min


调试发现: 这里获取单个星星的尺寸为0导致 // 获取单个星星的尺寸 getRateIconWrapRect() { // uView封装的获取节点的方法,详见文档 // #ifndef APP-NVUE this.$uGetRect("." + this.elClass).then((res) => { this.rateWidth = res.width; console.log('获取单个星星的尺寸', this.rateWidth); }); // #endif // #ifdef APP-NVUE dom.getComponentRect( this.$refs["u-rate__content__item__icon-wrap"][0], (res) => { this.rateWidth = res.size.width; } ); // #endif

yourVictor avatar Sep 22 '22 02:09 yourVictor

可能(我这边复现和尝试修复了一下) uni_modules\uview-ui\components\u-rate\u-rate.vue

// uView封装的获取节点的方法,详见文档
				// #ifndef APP-NVUE
					setTimeout(()=>{
						this.$uGetRect("." + this.elClass).then((res) => {
							this.rateWidth = res.width;
						});
					},100)
				// #endif

加个定时器,你可以试一试

ChenLiuPng avatar Sep 24 '22 09:09 ChenLiuPng

暂时看到的是 $uGetRect 使用过程中,获取宽度有问题,有问题的时候是17 没有问题的时候是24 你可以自己尝试一下 用官方的示例,然后去 uView2.0\uni_modules\uview-ui\libs\mixin\mixin.js

$uGetRect(selector, all) {
            return new Promise((resolve) => {
                uni.createSelectorQuery()
                    .in(this)[all ? 'selectAll' : 'select'](selector)
                    .boundingClientRect((rect) => {
						console.log(rect.width)
                        if (all && Array.isArray(rect) && rect.length) {
                            resolve(rect)
                        }
                        if (!all && rect) {
                            resolve(rect)
                        }
                    })
                    .exec()
            })
        },

加个打印 有问题的是17.xxxxx 点击没问题是24

ChenLiuPng avatar Sep 24 '22 10:09 ChenLiuPng