fix: async install config, fixed #425
This commit is contained in:
parent
ef1b42be23
commit
e4e011c81f
2 changed files with 61 additions and 59 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import {merge, hyphenate, isPrimitive, hasOwn} from './util/core'
|
import {merge, hyphenate, isPrimitive, hasOwn} from './util/core'
|
||||||
|
|
||||||
const config = merge(
|
export default function () {
|
||||||
|
const config = merge(
|
||||||
{
|
{
|
||||||
el: '#app',
|
el: '#app',
|
||||||
repo: '',
|
repo: '',
|
||||||
|
|
@ -27,15 +28,15 @@ const config = merge(
|
||||||
noCompileLinks: []
|
noCompileLinks: []
|
||||||
},
|
},
|
||||||
window.$docsify
|
window.$docsify
|
||||||
)
|
)
|
||||||
|
|
||||||
const script =
|
const script =
|
||||||
document.currentScript ||
|
document.currentScript ||
|
||||||
[].slice
|
[].slice
|
||||||
.call(document.getElementsByTagName('script'))
|
.call(document.getElementsByTagName('script'))
|
||||||
.filter(n => /docsify\./.test(n.src))[0]
|
.filter(n => /docsify\./.test(n.src))[0]
|
||||||
|
|
||||||
if (script) {
|
if (script) {
|
||||||
for (const prop in config) {
|
for (const prop in config) {
|
||||||
if (hasOwn.call(config, prop)) {
|
if (hasOwn.call(config, prop)) {
|
||||||
const val = script.getAttribute('data-' + hyphenate(prop))
|
const val = script.getAttribute('data-' + hyphenate(prop))
|
||||||
|
|
@ -61,8 +62,9 @@ if (script) {
|
||||||
if (config.name === true) {
|
if (config.name === true) {
|
||||||
config.name = ''
|
config.name = ''
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.$docsify = config
|
||||||
|
|
||||||
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
window.$docsify = config
|
|
||||||
|
|
||||||
export default config
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {isFn} from '../util/core'
|
||||||
export function initMixin(proto) {
|
export function initMixin(proto) {
|
||||||
proto._init = function () {
|
proto._init = function () {
|
||||||
const vm = this
|
const vm = this
|
||||||
vm.config = config || {}
|
vm.config = config()
|
||||||
|
|
||||||
initLifecycle(vm) // Init hooks
|
initLifecycle(vm) // Init hooks
|
||||||
initPlugin(vm) // Install plugins
|
initPlugin(vm) // Install plugins
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue