Skip to content

Commit cc56ada

Browse files
committed
fix: cannot read property 'getBoundingClientRect' of undefined
1 parent 9b69a30 commit cc56ada

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

README.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export default {
155155
| on-refresh | Will be Emitted when pull refresh | _function_ | - |
156156
| pulling-text | The Text when pulling in refresh | _string_ | `Pull down to refresh` |
157157
| loosing-text | The Text when loosing in refresh | _string_ | `Loosing to refresh` |
158-
| loading-text | The Text when loading in refresh | _string_ | `Refreshing` |
158+
| refresh-text | The Text when loading in refresh | _string_ | `Refreshing` |
159159
| success-text | The Text when loading success in refresh | _string_ | `Refresh success` |
160160
| show-success-text | Whether to show `success-text` | _boolean_ | `true` |
161161
| pull-distance | The distance to trigger the refresh status | _number \| string_ | `50` |

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ export default {
155155
| on-refresh | 顶部下拉触发 | _function_ | - |
156156
| pulling-text | 下拉显示文本 | _string_ | `下拉刷新` |
157157
| loosing-text | 释放显示文本 | _string_ | `释放刷新` |
158-
| loading-text | 正在刷新显示文本 | _string_ | `正在刷新` |
158+
| refresh-text | 正在刷新显示文本 | _string_ | `正在刷新` |
159159
| success-text | 刷新完成显示文本 | _string_ | `刷新完成` |
160160
| show-success-text | 是否显示`success-text` | _boolean_ | `true` |
161161
| pull-distance | 触发正在刷新状态的距离 | _number \| string_ | `50` |
162162
| head-height | 正在刷新显示区域的高度 | _number \| string_ | `50` |
163163
| animation-duration | 下拉刷新动画持续时间 | _number \| string_ | `200` |
164164
| on-loadmore | 滚动到底部触发 | _function_ | - |
165-
| immediate-check | 是否在mounted之后立即检查 | _boolean_ | `true` |
165+
| immediate-check | 是否立即触发数据加载;默认是,否的话则自己定义触发数据加载时机 | _boolean_ | `true` |
166166
| load-offset | 当滚动条到底部的距离小于 `load-offset` 时,会发出 `on-loadmore` | _number \| string_ | `50` |
167167
| finished | 数据是否加载完毕,改变为true,则会显示`finished-text` | _boolean_ | `false` |
168168
| error | 数据是否加载错误,`on-loadmore`只有在点击错误文本时才会触发,需要`sync`修饰符 | _boolean_ | `false` |

lib/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuejs-loadmore",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "A pull-down refresh and pull-up loadmore scroll component for Vue.js",
55
"entry": "packages/index.js",
66
"main": "lib/index.js",
@@ -28,9 +28,6 @@
2828
],
2929
"author": "staticdeng",
3030
"license": "MIT",
31-
"dependencies": {
32-
"vue": "^2.6.14"
33-
},
3431
"devDependencies": {
3532
"@babel/core": "^7.16.0",
3633
"@babel/preset-env": "^7.16.4",
@@ -56,6 +53,7 @@
5653
"rollup-plugin-postcss": "^4.0.2",
5754
"rollup-plugin-terser": "^7.0.2",
5855
"rollup-plugin-vue": "^5.1.9",
56+
"vue": "^2.6.14",
5957
"vue-jest": "4.0.0-rc.0",
6058
"vue-template-compiler": "^2.6.14"
6159
},

packages/vuejs-loadmore/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ export default {
282282
}
283283
284284
const scrollerHeight = scrollerRect.bottom - scrollerRect.top;
285-
286-
if (!scrollerHeight) {
285+
const placeholder = this.$refs.placeholder;
286+
if (!scrollerHeight || !placeholder) {
287287
return false;
288288
}
289289
290-
const placeholderRect = this.$refs.placeholder.getBoundingClientRect();
290+
const placeholderRect = placeholder.getBoundingClientRect();
291291
// 取绝对值,placeholderRect在scrollerRect容器的正负loadOffset区间则达到底部
292292
const bottomReached = Math.abs(placeholderRect.bottom - scrollerRect.bottom) <= loadOffset;
293293

0 commit comments

Comments
 (0)