Skip to content

Instantly share code, notes, and snippets.

@nemanja947
Created January 25, 2018 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemanja947/5efef404d2c8e242b9d84dda4fb92b18 to your computer and use it in GitHub Desktop.
Save nemanja947/5efef404d2c8e242b9d84dda4fb92b18 to your computer and use it in GitHub Desktop.
<template>
<div id="app">
<!-- for example router view -->
<router-view></router-view>
</div>
</template>
<script>
export default {
mounted () {
// [App.vue specific] When App.vue is finish loading finish the progress bar
NProgress.done();
},
created () {
// [App.vue specific] When App.vue is first loaded start the progress bar
NProgress.start();
// hook the progress bar to start before we move router-view
this.$router.beforeEach((to, from, next) => {
// start the progress bar
NProgress.start();
// continue to next page
next()
})
// hook the progress bar to finish after we've finished moving router-view
this.$router.afterEach((to, from) => {
// finish the progress bar
NProgress.done();
})
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment