vue-easy-renderer
Version:
Vue.js 2.0 server-side renderer for *.vue file with Node.js.
22 lines (18 loc) • 664 B
JavaScript
const vueEasyRenderer = {};
vueEasyRenderer.install = (Vue, options) => {
Vue.mixin({
beforeCreate() {
if (this.$isServer || this.$parent) return;
const initState = window.__VUE_INITIAL_STATE__; //eslint-disable-line
if (this.$options.store && initState) {
this.$options.store.replaceState(Object.assign({}, this.$options.store.state, initState));
} else {
const data = typeof this.$options.data === 'function' ?
this.$options.data.call(this) :
this.$options.data || {};
this.$options.data = Object.assign({}, data, initState);
}
},
});
};
module.exports = vueEasyRenderer;