LoadingBar support SSR
This commit is contained in:
parent
dd28e57f27
commit
24c8f4eaba
1 changed files with 13 additions and 14 deletions
|
@ -1,24 +1,21 @@
|
||||||
import LoadingBar from './loading-bar.vue';
|
import LoadingBar from './loading-bar.vue';
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { camelcaseToHyphen } from '../../utils/assist';
|
|
||||||
|
|
||||||
LoadingBar.newInstance = properties => {
|
LoadingBar.newInstance = properties => {
|
||||||
const _props = properties || {};
|
const _props = properties || {};
|
||||||
|
|
||||||
let props = '';
|
const Instance = new Vue({
|
||||||
Object.keys(_props).forEach(prop => {
|
data: _props,
|
||||||
props += ' :' + camelcaseToHyphen(prop) + '=' + prop;
|
render (h) {
|
||||||
|
return h(LoadingBar, {
|
||||||
|
props: _props
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const div = document.createElement('div');
|
const component = Instance.$mount();
|
||||||
div.innerHTML = `<loading-bar${props}></loading-bar>`;
|
document.body.appendChild(component.$el);
|
||||||
document.body.appendChild(div);
|
const loading_bar = Instance.$children[0];
|
||||||
|
|
||||||
const loading_bar = new Vue({
|
|
||||||
el: div,
|
|
||||||
data: _props,
|
|
||||||
components: { LoadingBar }
|
|
||||||
}).$children[0];
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
update (options) {
|
update (options) {
|
||||||
|
@ -34,7 +31,9 @@ LoadingBar.newInstance = properties => {
|
||||||
},
|
},
|
||||||
component: loading_bar,
|
component: loading_bar,
|
||||||
destroy () {
|
destroy () {
|
||||||
document.body.removeChild(div);
|
setTimeout(function() {
|
||||||
|
document.body.removeChild(document.getElementsByClassName('ivu-loading-bar')[0].parentElement);
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue