Skip to content

Commit 72b93f2

Browse files
authored
Merge pull request #13 from mpvue/develop
更新slots生成机制, 规避emitFile策略造成的问题
2 parents ec131ab + 9f157b6 commit 72b93f2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/mp-compiler/index.js

+10-1
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)