Skip to content

Commit 64cf793

Browse files
committed
fix scoping error loadingRouteData example
1 parent e43c3f5 commit 64cf793

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/guide/migration-vue-router.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,20 +530,22 @@ data: function () {
530530
},
531531
watch: {
532532
'$route': function () {
533-
this.isLoading = true
534-
this.fetchData().then(() => {
535-
this.isLoading = false
533+
var self = this
534+
self.isLoading = true
535+
self.fetchData().then(function () {
536+
self.isLoading = false
536537
})
537538
}
538539
},
539540
methods: {
540541
fetchData: function () {
542+
var self = this
541543
return axios.get('/api/posts')
542544
.then(function (response) {
543-
this.posts = response.data.posts
545+
self.posts = response.data.posts
544546
})
545547
.catch(function (error) {
546-
this.fetchError = error
548+
self.fetchError = error
547549
})
548550
}
549551
}

0 commit comments

Comments
 (0)