Skip to content

Commit

Permalink
更新slots生成机制, 规避emitFile策略造成的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jyootai committed Apr 23, 2018
1 parent 2905ef5 commit 9f157b6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/mp-compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 9f157b6

Please sign in to comment.