Execute script when vue exists.
This commit is contained in:
parent
d179ade7df
commit
9abae495ac
4 changed files with 22 additions and 10 deletions
|
|
@ -98,9 +98,14 @@ export function renderArticle (content) {
|
|||
renderTo('article', content ? markdown(content) : 'not found')
|
||||
if (!OPTIONS.sidebar && !OPTIONS.loadSidebar) renderSidebar()
|
||||
|
||||
if (content && typeof Vue !== 'undefined' && typeof Vuep !== 'undefined') {
|
||||
const vm = new Vue({ el: 'main' }) // eslint-disable-line
|
||||
vm.$nextTick(_ => event.scrollActiveSidebar())
|
||||
if (content && typeof Vue !== 'undefined') {
|
||||
const script = content.match('<script[^>]*?>([^<]+)</script>')
|
||||
script && document.body.querySelector('article script').remove()
|
||||
|
||||
const vm = script
|
||||
? new Function(`return ${script[1].trim()}`)()
|
||||
: new Vue({ el: 'main' }) // eslint-disable-line
|
||||
vm && vm.$nextTick(_ => event.scrollActiveSidebar())
|
||||
}
|
||||
if (OPTIONS.auto2top) setTimeout(() => event.scroll2Top(OPTIONS.auto2top), 0)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue