mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix(vue-app): add prefetched
class to <nuxt-link>
after chunk loaded (#6623)
This commit is contained in:
parent
e3054314a9
commit
9f921fe136
@ -92,15 +92,18 @@ export default {
|
|||||||
// Stop observing this link (in case of internet connection changes)
|
// Stop observing this link (in case of internet connection changes)
|
||||||
observer.unobserve(this.$el)
|
observer.unobserve(this.$el)
|
||||||
const Components = this.getPrefetchComponents()
|
const Components = this.getPrefetchComponents()
|
||||||
|
<% if (router.linkPrefetchedClass) { %>const promises = []<% } %>
|
||||||
|
|
||||||
for (const Component of Components) {
|
for (const Component of Components) {
|
||||||
const componentOrPromise = Component()
|
const componentOrPromise = Component()
|
||||||
if (componentOrPromise instanceof Promise) {
|
if (componentOrPromise instanceof Promise) {
|
||||||
componentOrPromise.catch(() => {})
|
componentOrPromise.catch(() => {})
|
||||||
|
<% if (router.linkPrefetchedClass) { %>promises.push(componentOrPromise)<% } %>
|
||||||
}
|
}
|
||||||
Component.__prefetched = true
|
Component.__prefetched = true
|
||||||
}<% if (router.linkPrefetchedClass) { %>
|
}<% if (router.linkPrefetchedClass) { %>
|
||||||
this.addPrefetchedClass()<% } %>
|
return Promise.all(promises).then(() => this.addPrefetchedClass())
|
||||||
|
<% } %>
|
||||||
}<% if (router.linkPrefetchedClass) { %>,
|
}<% if (router.linkPrefetchedClass) { %>,
|
||||||
addPrefetchedClass () {
|
addPrefetchedClass () {
|
||||||
if (this.prefetchedClass !== 'false') {
|
if (this.prefetchedClass !== 'false') {
|
||||||
|
Loading…
Reference in New Issue
Block a user