mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Move $nuxt into App
This commit is contained in:
parent
48b5ff3bfc
commit
7d370d8126
@ -28,16 +28,36 @@ export default {
|
||||
layout: null,
|
||||
layoutName: ''
|
||||
}),
|
||||
beforeCreate () {
|
||||
Vue.util.defineReactive(this, 'nuxt', this.$options._nuxt)
|
||||
},
|
||||
created () {
|
||||
// Add this.$nuxt in child instances
|
||||
Vue.prototype.$nuxt = this
|
||||
// add to window so we can listen when ready
|
||||
if (typeof window !== 'undefined') {
|
||||
window.$nuxt = this
|
||||
}
|
||||
// Add $nuxt.error()
|
||||
this.error = this.nuxt.error
|
||||
},
|
||||
<% if (loading) { %>
|
||||
mounted () {
|
||||
this.$loading = this.$refs.loading
|
||||
this.$nuxt.$loading = this.$loading
|
||||
},
|
||||
watch: {
|
||||
'nuxt.err': 'errorChanged'
|
||||
},
|
||||
<% } %>
|
||||
beforeCreate () {
|
||||
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
|
||||
},
|
||||
methods: {
|
||||
<% if (loading) { %>
|
||||
errorChanged () {
|
||||
if (this.nuxt.err && this.$loading) {
|
||||
if (this.$loading.fail) this.$loading.fail()
|
||||
if (this.$loading.finish) this.$loading.finish()
|
||||
}
|
||||
},
|
||||
<% } %>
|
||||
setLayout (layout) {
|
||||
if (!layout || !resolvedLayouts['_' + layout]) layout = 'default'
|
||||
this.layoutName = layout
|
||||
|
@ -15,38 +15,6 @@ export default {
|
||||
beforeCreate () {
|
||||
Vue.util.defineReactive(this, 'nuxt', this.$root.$options._nuxt)
|
||||
},
|
||||
created () {
|
||||
// Add this.$nuxt in child instances
|
||||
Vue.prototype.$nuxt = this
|
||||
// Add this.$root.$nuxt
|
||||
this.$root.$nuxt = this
|
||||
// Bind $nuxt.setLayout(layout) to $root.setLayout
|
||||
this.setLayout = this.$root.setLayout.bind(this.$root)
|
||||
// add to window so we can listen when ready
|
||||
if (typeof window !== 'undefined') {
|
||||
window.$nuxt = this
|
||||
}
|
||||
// Add $nuxt.error()
|
||||
this.error = this.$root.error
|
||||
},
|
||||
<% if (loading) { %>
|
||||
mounted () {
|
||||
if (this.$root.$loading && this.$root.$loading.start) {
|
||||
this.$loading = this.$root.$loading
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'nuxt.err': 'errorChanged'
|
||||
},
|
||||
methods: {
|
||||
errorChanged () {
|
||||
if (this.nuxt.err && this.$loading) {
|
||||
if (this.$loading.fail) this.$loading.fail()
|
||||
if (this.$loading.finish) this.$loading.finish()
|
||||
}
|
||||
}
|
||||
},
|
||||
<% } %>
|
||||
computed: {
|
||||
routerViewKey () {
|
||||
// If nuxtChildKey prop is given or current route has children
|
||||
|
Loading…
Reference in New Issue
Block a user