From 9f157b6d2c3f23f8570c6cc6670a0c1bd4ad819c Mon Sep 17 00:00:00 2001 From: jyootai Date: Mon, 23 Apr 2018 10:22:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0slots=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=9C=BA=E5=88=B6,=20=E8=A7=84=E9=81=BFemitFile=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E9=80=A0=E6=88=90=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mp-compiler/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/mp-compiler/index.js b/lib/mp-compiler/index.js index 69076b7..d714eba 100644 --- a/lib/mp-compiler/index.js +++ b/lib/mp-compiler/index.js @@ -22,11 +22,20 @@ const { getPageSrc } = require('./util') +let emitFileTimer = null + function createSlotsWxml (emitFile, slots, importCode) { cacheSlots(slots, importCode) const content = getSlots() + // 100 delay 比较符合当前策略 + const delay = 100 if (content.trim()) { - emitFile('components/slots.wxml', htmlBeautify(content)) + if (emitFileTimer) { + clearTimeout(emitFileTimer) + } + emitFileTimer = setTimeout(function () { + emitFile('components/slots.wxml', htmlBeautify(content)) + }, delay) } }