在谷歌浏览器中使用scrollTop++会失效,是因为scrolltop++会解析成1*window.devicePixelRatio,
而在浏览器缩放时,window.devicePixelRatio会变成比1还小,所以会导致scrollTop++一直是0,此时使用下方代码就可以解决了,+ 0.05 是为了防止有的缩放比例还是会小于1,相当于做个保障
this.$refs.scrollableContainer.scrollTop++;
// 换成下方代码
// 谷歌内核就要使用不同的方法,不能直接++
if (
navigator.userAgent.indexOf("Chrome") !== -1 &&
navigator.userAgent.indexOf("Safari") !== -1 &&
navigator.userAgent.indexOf("Edg") === -1
) {
this.$refs.scrollableContainer.scrollTop +=
1 / window.devicePixelRatio + 0.05;
} else {
// 否则滚动条长度++
this.$refs.scrollableContainer.scrollTop++;
}