From 1b18b86bbf1b29a9fba337c9905b0395d8a072af Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Mon, 14 Dec 2020 14:22:42 +0800 Subject: [PATCH] 实现无限滚动 --- bases/Pilot.js | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bases/Pilot.js b/bases/Pilot.js index a8fc753..bc09f48 100644 --- a/bases/Pilot.js +++ b/bases/Pilot.js @@ -12,7 +12,7 @@ return {}; } - createOptions() { + createOptions(dataAdd) { const options = { methods: {}, }; @@ -21,7 +21,18 @@ return; } if (/^\$/.test(name)) { - options[name.replace('$', '')] = this[name]; + if (name === '$data' && typeof dataAdd !== 'undefined') { + // 当有传data值进来,初始值必须带data中的字段 + const dataOrig = this.$data(); + options.data = () => { + return { + ...dataOrig, + ...dataAdd, + } + } + } else { + options[name.replace('$', '')] = this[name]; + } } else { options.methods[name] = this[name]; } -- Gitblit v1.9.1