mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
chore: use data-fetch-key instead of data-ssr-key
This commit is contained in:
parent
539c865533
commit
b71eaee879
@ -1,7 +1,7 @@
|
||||
import Vue from 'vue'
|
||||
import { hasFetch, normalizeError, addLifecycleHook } from '../utils'
|
||||
|
||||
const isSsrHydration = (vm) => vm.$vnode && vm.$vnode.elm && vm.$vnode.elm.dataset && vm.$vnode.elm.dataset.ssrKey
|
||||
const isSsrHydration = (vm) => vm.$vnode && vm.$vnode.elm && vm.$vnode.elm.dataset && vm.$vnode.elm.dataset.fetchKey
|
||||
const nuxtState = window.<%= globals.context %>
|
||||
|
||||
export default {
|
||||
@ -37,8 +37,8 @@ function created() {
|
||||
|
||||
// Hydrate component
|
||||
this._hydrated = true
|
||||
this._ssrKey = +this.$vnode.elm.dataset.ssrKey
|
||||
const data = nuxtState.fetch[this._ssrKey]
|
||||
this._fetchKey = +this.$vnode.elm.dataset.fetchKey
|
||||
const data = nuxtState.fetch[this._fetchKey]
|
||||
|
||||
// If fetch error
|
||||
if (data && data._error) {
|
||||
|
@ -16,13 +16,13 @@ async function serverPrefetch() {
|
||||
|
||||
|
||||
// Define an ssrKey for hydration
|
||||
this._ssrKey = this.$ssrContext.nuxt.fetch.length
|
||||
this._fetchKey = this.$ssrContext.nuxt.fetch.length
|
||||
|
||||
// Add data-ssr-key on parent element of Component
|
||||
// Add data-fetch-key on parent element of Component
|
||||
const attrs = this.$vnode.data.attrs = this.$vnode.data.attrs || {}
|
||||
attrs['data-ssr-key'] = this._ssrKey
|
||||
attrs['data-fetch-key'] = this._fetchKey
|
||||
|
||||
// Call asyncData & add to ssrContext for window.__NUXT__.fetch
|
||||
// Add to ssrContext for window.__NUXT__.fetch
|
||||
this.$ssrContext.nuxt.fetch.push(this.$fetchState.error ? { _error: this.$fetchState.error } : this._data)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user