fix initialize the Vue instance

This commit is contained in:
qingwei.li 2017-01-28 11:11:58 +08:00
commit 3ec7c89bbb

View file

@ -112,12 +112,13 @@ export function renderArticle (content) {
document.body.querySelectorAll('article>script')) document.body.querySelectorAll('article>script'))
.filter(script => !/template/.test(script.type) .filter(script => !/template/.test(script.type)
)[0] )[0]
const code = script ? script.innerText.trim() : null
CACHE.vm = script script && script.remove()
? new Function(`return ${script.innerText.trim()}`)() CACHE.vm = code
? new Function(`return ${code}`)()
: new Vue({ el: 'main' }) // eslint-disable-line : new Vue({ el: 'main' }) // eslint-disable-line
CACHE.vm && CACHE.vm.$nextTick(_ => event.scrollActiveSidebar()) CACHE.vm && CACHE.vm.$nextTick(_ => event.scrollActiveSidebar())
script && script.remove()
} }
if (OPTIONS.auto2top) setTimeout(() => event.scroll2Top(OPTIONS.auto2top), 0) if (OPTIONS.auto2top) setTimeout(() => event.scroll2Top(OPTIONS.auto2top), 0)
} }