fix(render): init event in ssr

This commit is contained in:
qingwei.li 2017-05-30 01:25:52 +08:00 • committed by cinwell.li
commit eba1c987a8
6 changed files with 68 additions and 12 deletions

View file

@ -2,6 +2,7 @@ import { get } from './ajax'
import { callHook } from '../init/lifecycle'
import { getParentPath } from '../router/util'
import { noop } from '../util/core'
import { getAndActive } from '../event/sidebar'
function loadNested (path, file, next, vm, first) {
path = first ? path : path.replace(/\/$/, '')
@ -70,7 +71,15 @@ export function fetchMixin (proto) {
}
export function initFetch (vm) {
const { loadSidebar } = vm.config
// server-client renderer
if (vm.rendered) {
const activeEl = getAndActive(vm.router, '.sidebar-nav', true, true)
if (loadSidebar && activeEl) {
activeEl.parentNode.innerHTML += window.__SUB_SIDEBAR__
}
vm._bindEventOnRendered(activeEl)
vm._fetchCover()
vm.$resetEvents()
callHook(vm, 'doneEach')