From cf5a9833848f255485e0f905bc2c0a98478692ee Mon Sep 17 00:00:00 2001 From: mh <929571370@qq.com> Date: Fri, 6 Mar 2020 15:30:08 +0800 Subject: [PATCH 1/2] add judgments if next doesnot exist --- src/components/sticky/sticky.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/sticky/sticky.js b/src/components/sticky/sticky.js index a075e39a6..800f2f095 100755 --- a/src/components/sticky/sticky.js +++ b/src/components/sticky/sticky.js @@ -53,10 +53,10 @@ export default function (nav, options = {}) { const getFillElem = function (el) { let next = el.nextSibling // 寻找最近的一个兄弟元素 - while (next.nodeType !== 1) { + while (next && next.nodeType !== 1) { next = next.nextSibling } - if (next.classList.contains('vux-sticky-fill')) { + if (next && next.classList.contains('vux-sticky-fill')) { return next } // 没有使用vux-sticky-fill按照之前的方式获取外层容器 From b10868c5c85baf8dc7266d70aa9bf3d8685e5617 Mon Sep 17 00:00:00 2001 From: mh <929571370@qq.com> Date: Fri, 6 Mar 2020 16:14:35 +0800 Subject: [PATCH 2/2] add judgments if next doesnot exist --- src/components/sticky/sticky.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/sticky/sticky.js b/src/components/sticky/sticky.js index 800f2f095..a6da37272 100755 --- a/src/components/sticky/sticky.js +++ b/src/components/sticky/sticky.js @@ -53,10 +53,10 @@ export default function (nav, options = {}) { const getFillElem = function (el) { let next = el.nextSibling // 寻找最近的一个兄弟元素 - while (next && next.nodeType !== 1) { + while (!!next && next.nodeType !== 1) { next = next.nextSibling } - if (next && next.classList.contains('vux-sticky-fill')) { + if (!!next && next.classList.contains('vux-sticky-fill')) { return next } // 没有使用vux-sticky-fill按照之前的方式获取外层容器