add: store. & this.

This commit is contained in:
Sebastien Chopin 2017-09-14 18:25:34 +02:00
parent adbf0cdc3c
commit 53dc522849

View File

@ -43,7 +43,11 @@ const defaultTransition = <%=
async function createApp (ssrContext) { async function createApp (ssrContext) {
const router = createRouter() const router = createRouter()
<% if (store) { %>const store = createStore()<% } %> <% if (store) { %>
const store = createStore()
// Add this.$router into store actions/mutations
store.$router = router
<% } %>
// Create Root instance // Create Root instance
// here we inject the router and store to all child components, // here we inject the router and store to all child components,
@ -151,6 +155,9 @@ async function createApp (ssrContext) {
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %> if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %>
}<% } %> }<% } %>
// Inject context
inject('ctx', ctx)
if (process.server && ssrContext && ssrContext.url) { if (process.server && ssrContext && ssrContext.url) {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
router.push(ssrContext.url, resolve, reject) router.push(ssrContext.url, resolve, reject)