diff --git a/components/hospital-select/index.js b/components/hospital-select/index.js index 94c20b7..aed81e8 100644 --- a/components/hospital-select/index.js +++ b/components/hospital-select/index.js @@ -33,6 +33,9 @@ Component({ placeholder: { type: String, value: '请选择就诊医院' }, disabled: { type: Boolean, value: false }, compact: { type: Boolean, value: false }, + // 默认由组件自己上滚页面;放在弹窗内的 scroll-view 时, + // 页面滚动无法带动弹窗内容,需置 false 交给页面做容器内滚动 + autoPageScroll: { type: Boolean, value: true }, // 展开面板上滚时,医院行锚定到距页面顶部的距离(rpx); // 传入上方行的总高度,可让「就诊人姓名」等上一行滚到页面顶部 scrollAnchorOffset: { type: Number, value: 0 }, @@ -72,6 +75,9 @@ Component({ } this.setData({ open: true, keyword: '', manualEntry: false }) this.refreshFiltered(this.data.options, '') + // 页面可监听 open 事件,在自定义滚动容器内做定位 + this.triggerEvent('open') + if (!this.data.autoPageScroll) return // 面板展开后若被页面底部遮挡,自动上滚页面,保证下拉列表完整可见 wx.nextTick(() => this.scrollPanelIntoView()) },