mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Update no-ssr to v0.2.1
This commit is contained in:
parent
9bf73b0b5a
commit
dac47d43bf
@ -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('<no-ssr> 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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user