diff --git a/lib/app/components/no-ssr.js b/lib/app/components/no-ssr.js index 9dbc5bcbf5..637e828ab7 100644 --- a/lib/app/components/no-ssr.js +++ b/lib/app/components/no-ssr.js @@ -5,24 +5,31 @@ export default { name: 'no-ssr', props: ['placeholder'], - data () { + data() { return { canRender: false } }, - mounted () { + mounted() { this.canRender = true }, - render (h) { + render(h) { if (this.canRender) { if ( process.env.NODE_ENV === 'development' && + this.$slots.default && this.$slots.default.length > 1 ) { - throw new Error(' You cannot use multiple child components') + throw new Error('[vue-no-ssr] You cannot use multiple child components') } - return this.$slots.default[0] + return this.$slots.default && this.$slots.default[0] } - return h('div', { class: { 'no-ssr-placeholder': true } }, this.placeholder) + return h( + 'div', + { + class: ['no-ssr-placeholder'] + }, + this.placeholder + ) } }