How to pass an object as props with vue router?

It can work by using props’s Function mode and params Vue 2 demo: https://jsfiddle.net/hacg6ody/ when adding routes, use props’s Function mode so that it has a default property user and it will add route.params as props. { path: ‘/create’, name: ‘create’, component: CreateComponent, props: (route) => ({ user: userData, …route.params }) } params passed in … Read more

Detect Back Button in Navigation Guards of Vue-Router

This is the only way that I’ve found: We can listen for popstate, save it in a variable, and then check that variable // This listener will execute before router.beforeEach only if registered // before vue-router is registered with Vue.use(VueRouter) window.popStateDetected = false window.addEventListener(‘popstate’, () => { window.popStateDetected = true }) router.beforeEach((to, from, next) => … Read more

Can we make vue.js application without .vue extension component and webpack?

As stated in this jsFiddle: http://jsfiddle.net/posva/wtpuevc6/ , you have no obligation to use webpack or .vue files. The code below is not from me and all credit goes to this jsFiddle creator: Create an index.html file: <script src=”https://npmcdn.com/vue/dist/vue.js”></script> <script src=”https://npmcdn.com/vue-router/dist/vue-router.js”></script> <script src=”/js/Home.js”></script> <script src=”/js/Foo.js”></script> <script src=”/js/router.js”></script> <script src=”/js/index.js”></script> <div id=”app”> <router-link to=”https://stackoverflow.com/”>/home</router-link> <router-link to=”/foo”>/foo</router-link> <router-view></router-view> … Read more

How to make dynamic routes on the vue router?

I suppose getDetailMenu is calling API method to get listMenu. You can create route dynamically using addRoutes method Pseudo code created() { this.getDetailMenu(this.$route.path) .then((listMenu) => { // you need to return listMenu from getDetailMenu listMenu.forEach((item, index) => createAndAppendRoute(item, index)) }) }, methods: { createAndAppendRoute: (item, index) => { console.log(item, index) // Base on your data, … Read more