How to access async store data in vue-router for usage in beforeEnter hook?

You can do it by returning a promise from vuex action, as it is explained here and call the dispatch from within the beforeEnter itself. Code should look like following: import store from ‘./vuex/store’; // following is an excerpt of the routes object: { path: ‘/example’, component: Example, beforeEnter: (to, from, next) => { store.dispatch(‘initApp’).then(response … Read more

How to display a “loading” animation while a lazy-loaded route component is being loaded?

You can use navigation guards to activate/deactivate a loading state that shows/hides a loading component: If you would like to use something like “nprogress” you can do it like this: http://jsfiddle.net/xgrjzsup/2669/ const router = new VueRouter({ routes }) router.beforeEach((to, from, next) => { NProgress.start() next() }) router.afterEach(() => { NProgress.done() }) Alternatively, if you want … Read more

Vue-Test-Utils Unknown custom element:

Add the router-link stub to the shallow (or shallowMount) method options like this: const wrapper = shallow(TempComponent, { propsData: { temp }, stubs: [‘router-link’] }) or this way: import { RouterLinkStub } from ‘@vue/test-utils’; const wrapper = shallow(TempComponent, { propsData: { temp }, stubs: { RouterLink: RouterLinkStub } }) The error should go away after … Read more

Access VueRouter outside Vue components

I’ve used it only from components but you could try following in case you’re using common boilerplate where routes are defined under router/index.js then you just import it like: import Router from ‘../router’; After it is possible to use it in code e.g. Router.push(‘/mypage’) Not sure if it works but give it a try.

Vue.js page transition fade effect with vue-router

Wrap <router-view></router-view> with <transition name=”fade”></transition> and add these styles: .fade-enter-active, .fade-leave-active { transition-property: opacity; transition-duration: .25s; } .fade-enter-active { transition-delay: .25s; } .fade-enter, .fade-leave-active { opacity: 0 } Detailed answer Assuming you have created your application with vue-cli, e.g.: vue init webpack fadetransition cd fadetransition npm install Install the router: npm i vue-router If you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)