Skip to content

Commit

Permalink
Merge pull request #1262 from didi/fix_web_compile
Browse files Browse the repository at this point in the history
Fix web compile
  • Loading branch information
hiyuki authored Sep 7, 2023
2 parents a0d7f01 + 1d78b06 commit 7dd763e
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
},
watch: {
scrollIntoView (val) {
this.bs && this.bs.scrollToElement('#' + val, this.scrollWithAnimation ? 200 : 0)
this.scrollToView(val, this.scrollWithAnimation ? 200 : 0)
},
_scrollTop (val) {
this.bs && this.bs.scrollTo(this.bs.x, -val, this.scrollWithAnimation ? 200 : 0)
Expand Down Expand Up @@ -201,9 +201,7 @@
leading: true,
trailing: false
}))
if (this.scrollIntoView) {
this.bs.scrollToElement('#' + this.scrollIntoView)
}
if (this.scrollIntoView) this.scrollToView(this.scrollIntoView)
// 若开启自定义下拉刷新 或 开启 scroll-view 增强特性
if (this.refresherEnabled || this.enhanced) {
const actionsHandlerHooks = this.bs.scroller.actionsHandler.hooks
Expand Down Expand Up @@ -258,6 +256,12 @@
}
}
},
scrollToView (id, duration = 0) {
if (!id) return
id = '#' + id
if (!document.querySelector(id)) return // 不存在元素时阻断,直接调用better-scroll的方法会报错
this.bs?.scrollToElement(id, duration)
},
initLayerComputed () {
const wrapper = this.$refs.wrapper
const wrapperWidth = wrapper.offsetWidth
Expand Down

0 comments on commit 7dd763e

Please sign in to comment.