Skip to content

Commit 9f157b6

Browse files
committed
更新slots生成机制, 规避emitFile策略造成的问题
1 parent 2905ef5 commit 9f157b6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/mp-compiler/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@ const {
2222
getPageSrc
2323
} = require('./util')
2424

25+
let emitFileTimer = null
26+
2527
function createSlotsWxml (emitFile, slots, importCode) {
2628
cacheSlots(slots, importCode)
2729
const content = getSlots()
30+
// 100 delay 比较符合当前策略
31+
const delay = 100
2832
if (content.trim()) {
29-
emitFile('components/slots.wxml', htmlBeautify(content))
33+
if (emitFileTimer) {
34+
clearTimeout(emitFileTimer)
35+
}
36+
emitFileTimer = setTimeout(function () {
37+
emitFile('components/slots.wxml', htmlBeautify(content))
38+
}, delay)
3039
}
3140
}
3241

0 commit comments

Comments
 (0)