From 40a683c1b50813d111b1ac7463b8160dd53995ac Mon Sep 17 00:00:00 2001 From: Roy Tam Date: Tue, 24 Sep 2019 22:47:28 +0800 Subject: [PATCH] add a guard for function inside setTimeout. --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 6ae3b40..1eb5036 100644 --- a/src/index.js +++ b/src/index.js @@ -29,8 +29,10 @@ const Loading = function (options = {}) { loading.show = false; this.instance && (this.instance = null); setTimeout(() => { - loading.$el.parentNode && loading.$el.parentNode.removeChild(loading.$el); - loading.$destroy(); + if (loading) { + loading.$el.parentNode && loading.$el.parentNode.removeChild(loading.$el); + loading.$destroy(); + } loading = null; target._isLoading = false; }, 500);