refactor(core): add render

This commit is contained in:
qingwei.li 2017-02-17 23:09:09 +08:00 committed by cinwell.li
commit 8bee8f0213
20 changed files with 232 additions and 102 deletions

View file

@ -9,7 +9,7 @@ import { isFn } from '../util/core'
export function initMixin (Docsify) {
Docsify.prototype._init = function () {
const vm = this
vm._config = config || {}
vm.config = config || {}
initLifecycle(vm) // Init hooks
initPlugin(vm) // Install plugins
@ -23,5 +23,5 @@ export function initMixin (Docsify) {
}
function initPlugin (vm) {
[].concat(vm.config.plugins).forEach(fn => isFn(fn) && fn(vm.bindHook))
[].concat(vm.config.plugins).forEach(fn => isFn(fn) && fn(vm._lifecycle, vm))
}

View file

@ -4,10 +4,10 @@ export function initLifecycle (vm) {
const hooks = ['init', 'beforeEach', 'afterEach', 'doneEach', 'ready']
vm._hooks = {}
vm.bindHook = {}
vm._lifecycle = {}
hooks.forEach(hook => {
const arr = vm._hooks[hook] = []
vm._bindHook[hook] = fn => arr.push(fn)
vm._lifecycle[hook] = fn => arr.push(fn)
})
}