docs: add executeScript demo

This commit is contained in:
qingwei.li 2017-02-18 23:04:52 +08:00 committed by cinwell.li
commit 3e7d6ab26c
6 changed files with 125 additions and 4 deletions

View file

@ -14,7 +14,9 @@ function executeScript () {
const code = script.innerText.trim()
if (!code) return false
window.__EXECUTE_RESULT__ = new Function('return ' + code)()
setTimeout(_ => {
window.__EXECUTE_RESULT__ = new Function(code)()
}, 0)
}
function renderMain (html) {
@ -31,11 +33,13 @@ function renderMain (html) {
if (!this.config.executeScript &&
typeof window.Vue !== 'undefined' &&
!executeScript()) {
window.__EXECUTE_RESULT__ = new window.Vue().$mount('#main')
setTimeout(_ => {
window.__EXECUTE_RESULT__ = new window.Vue().$mount('#main')
}, 0)
}
if (this.config.auto2top) {
setTimeout(() => scroll2Top(this.config.auto2top), 0)
scroll2Top(this.config.auto2top)
}
}