Skip to content

Commit b032041

Browse files
committed
compatible vuep, fixed QingWei-Li/vuep/issues/2
1 parent 4a77b8a commit b032041

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/render.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,17 @@ export function renderArticle (content) {
106106
if (!OPTIONS.sidebar && !OPTIONS.loadSidebar) renderSidebar()
107107

108108
if (content && typeof Vue !== 'undefined') {
109-
const script = content.match('<script[^>]*?>([^<]+)</script>')
110-
111-
script && document.body.querySelector('article script').remove()
112109
CACHE.vm && CACHE.vm.$destroy()
113-
CACHE.vm = script
114-
? new Function(`return ${script[1].trim()}`)()
110+
111+
const script = [].slice.call(
112+
document.body.querySelectorAll('article>script'))
113+
.filter(script => !/template/.test(script.type)
114+
)[0]
115+
116+
CACHE.vm = script && script.remove()
117+
? new Function(`return ${script.innerText.trim()}`)()
115118
: new Vue({ el: 'main' }) // eslint-disable-line
119+
116120
CACHE.vm && CACHE.vm.$nextTick(_ => event.scrollActiveSidebar())
117121
}
118122
if (OPTIONS.auto2top) setTimeout(() => event.scroll2Top(OPTIONS.auto2top), 0)

0 commit comments

Comments
 (0)