Fix issue #829 with onNuxtReady undefined

This commit is contained in:
Sebastien Chopin 2017-06-02 12:15:38 +02:00
parent 43de27faef
commit ea03d76e85

View File

@ -12,9 +12,19 @@ import App from '<%= appPath %>'
import { getContext } from './utils' import { getContext } from './utils'
if (process.browser) {
// window.onNuxtReady(() => console.log('Ready')) hook
// Useful for jsdom testing or plugins (https://github.com/tmpvar/jsdom#dealing-with-asynchronous-script-loading)
window._nuxtReadyCbs = []
window.onNuxtReady = function (cb) {
window._nuxtReadyCbs.push(cb)
}
}
// Import SSR plugins // Import SSR plugins
<% plugins.forEach(function (plugin) { if (plugin.ssr) <% plugins.forEach(function (plugin) { if (plugin.ssr)
{ %>import <%= plugin.name %> from '<%= r(plugin.src) %>' { %>let <%= plugin.name %> = require('<%= r(plugin.src) %>')
<%= plugin.name %> = <%= plugin.name %>.default || <%= plugin.name %>
<% }}) %> <% }}) %>
// Component: <nuxt-child> // Component: <nuxt-child>
@ -58,12 +68,6 @@ async function createApp (ssrContext) {
store.replaceState(window.__NUXT__.state) store.replaceState(window.__NUXT__.state)
} }
<% } %> <% } %>
// window.onNuxtReady(() => console.log('Ready')) hook
// Useful for jsdom testing or plugins (https://github.com/tmpvar/jsdom#dealing-with-asynchronous-script-loading)
window._nuxtReadyCbs = []
window.onNuxtReady = function (cb) {
window._nuxtReadyCbs.push(cb)
}
} }
// root instance // root instance