refactor client.js createApp using async/await

This commit is contained in:
Pooya Parsa 2017-05-26 16:11:18 +04:30
parent ae0c88acbf
commit a58b85a238

View File

@ -356,23 +356,15 @@ function nuxtReady (app) {
} }
createApp() createApp()
.then((__app) => { .then(async (__app) => {
app = __app.app app = __app.app
router = __app.router router = __app.router
<%= (store ? 'store = __app.store' : '') %> <%= (store ? 'store = __app.store' : '') %>
return Promise.all(resolveComponents(router)) const Components = await Promise.all(resolveComponents(router))
})
.then((Components) => {
const _app = new Vue(app) const _app = new Vue(app)
const layout = NUXT.layout || 'default'
let layout = NUXT.layout || 'default' await _app.loadLayout(layout)
return _app.loadLayout(layout) _app.setLayout(layout)
.then(() => {
_app.setLayout(layout)
return { _app, Components }
})
})
.then(({ _app, Components }) => {
const mountApp = () => { const mountApp = () => {
_app.$mount('#__nuxt') _app.$mount('#__nuxt')
Vue.nextTick(() => { Vue.nextTick(() => {