-
定位到 _getRateCount(获取星星个数) 方法,进行替换,替换代码如下。
/** * 获取星星个数 */ _getRateCount(clientX) { this._getSize() const size = Number(this.size) if(size === NaN){ return new Error('size 属性只能设置为数字') } const rateMoveRange = clientX - this._rateBoxLeft let index = parseInt(rateMoveRange / (size/2 + this.marginNumber)) index = index < 0 ? 0 : index; index = index > this.max ? this.max : index; const range = parseInt(rateMoveRange - (size/2 + this.marginNumber) * index); let value = 0; if (this._oldValue === index && !this.PC) return; this._oldValue = index; if (this.allowHalf) { if (range > (size / 2)) { value = index + 1 } else { value = index + 0.5 } } else { value = index + 1 } value = Math.max(0.5, Math.min(value, this.max)) this.valueSync = value this._onChange() },
原因
rpx和px问题
let index = parseInt(rateMoveRange / (size + this.marginNumber)) -> let index = parseInt(rateMoveRange / (size/2 + this.marginNumber))
const range = parseInt(rateMoveRange - (size + this.marginNumber) index); -> const range = parseInt(rateMoveRange - (size/2 + this.marginNumber) index
1 个评论
要回复文章请先登录或注册
8***@qq.com