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) } }