Skip to content

How can I set a default route on page load #866

@PanicIsReal

Description

@PanicIsReal

I'm trying to use vue-router with electron.js to make a desktop app, I currently have these routes

import Home from './views/Home/Home.vue';

export default [
  // Home Routes
  { path: '', name: 'home', component: Home },
  { path: '/', name: 'home', component: Home },
  { path: '*', redirect: '/' }

  
]

Currently when the program loads, window.location.pathname is something like /Users/name/appname/app/views/index.html' which doesn't match ANY of my paths, so I use a path: '*', redirect: '/' to send it to the home page on initial load.

I feel like there should be a better way to set a default route on initial load, is there nothing like

<router-view default="{name: 'home'}"></router-view> or something

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions