GithubHelp home page GithubHelp logo

vuejs / router Goto Github PK

View Code? Open in Web Editor NEW
3.6K 55.0 1.1K 9.94 MB

🚦 The official router for Vue.js

Home Page: https://router.vuejs.org/

License: MIT License

TypeScript 82.27% HTML 1.15% JavaScript 10.13% Vue 5.98% Shell 0.08% CSS 0.39%
vue vue-router

router's Introduction

vue-router release candidate test

  • This is the repository for Vue Router 4 (for Vue 3)
  • For Vue Router 3 (for Vue 2) see vuejs/vue-router.

Supporting Vue Router

Vue Router is part of the Vue Ecosystem and is an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:

Silver Sponsors

VueMastery Prefect

Bronze Sponsors

Stanislas Ormières Antony Konstantinidis Storyblok Nuxt UI Pro Templates


Get started with the documentation.

Quickstart

  • Via CDN: <script src="https://unpkg.com/vue-router@4"></script>

  • In-browser playground on CodeSandbox

  • Add it to an existing Vue Project:

    npm install vue-router@4

Changes from Vue Router 3

Please consult the Migration Guide.

Contributing

See Contributing Guide.

Special Thanks

BrowserStack Logo

Special thanks to BrowserStack for letting the maintainers use their service to debug browser specific issues.

router's People

Contributors

94mashiro avatar akimotorakiyu avatar bboyakers avatar danielkellyio avatar dependabot-preview[bot] avatar dependabot[bot] avatar edison1105 avatar fnlctrl avatar heygsc avatar jinjiang avatar laygir avatar leemove avatar lightnoway avatar lmmmmmm-bb avatar make17better avatar monsterpi13 avatar niceplugin avatar nicodevs avatar peteralfredlee avatar pikax avatar posva avatar rahaug avatar skirtles-code avatar sno2 avatar sourabh504 avatar webfansplz avatar wenfangdu avatar ydcjeff avatar yionr avatar yyx990803 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

router's Issues

Required "redirect" param when init RouteRecordRaw

I got this the error from es-lint

Property 'redirect' is missing in type '{ path: string; component: typeof import("[PATH]/node_modules/vue/dist/vue"); }' but req...

This is my implementation:

import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import Home from '../views/Home.vue';

const routes:RouteRecordRaw[] = [
        // I GOT THE ERROR HERE 
	{
		path: '/',
		component: Home
	}
];

const router = createRouter({
	history: createWebHistory(process.env.BASE_URL),
	routes: routes
});

export default router;

Why redirect is required? aw

I checked the type and it is

export type RouteRecordRaw =
  | RouteRecordSingleView
  | RouteRecordMultipleViews
  | RouteRecordRedirectRaw

so one of the 3 options. But why it pick the RedirectRaw? it should pick the SingleView right?

My setup

"vue": "^3.0.0-beta.14",
"vue-router": "^4.0.0-alpha.12",
"vuex": "^4.0.0-alpha.2" 

KeepAlive not working in VueRouter

Version

4.0.0-alpha.11

Reproduction link

https://github.com/andrewspy/vite-app-keep-alive

Steps to reproduce

See App.vue

<template>
  <h1>Hello Vite   Vue 3!</h1>
  <p>Edit ./App.vue to test hot module replacement (HMR).</p>
  <p>
    <span>Count is: {{ count }}</span>
    <button @click="count  ">increment</button>
  </p>
  <div>
    <hr />
    <router-link to="/">Home</router-link> |
    <router-link to="/about">About</router-link>
    <hr />
    <!-- XXX: keep-alive not working with vue-router-next -->
    <keep-alive :include="['Home', 'About']">
      <router-view />
    </keep-alive>
  </div>
</template>

What is expected?

count in Home view should retain value on change route.

What is actually happening?

count in Home view always reset to 0.


I have read the missing features of KeepAlive in README, but not sure if it is related, or any workaround for KeepAlive for Vue3.

Consider exporting the full type of the RouterLink and RouterView component for TypeScript

What problem does this feature solve?

As it stands now, attempting to use RouterLink or RouterView in TSX fails with:

TS2604: JSX element type 'RouterLink' does not have any construct or call signatures.

This is because the type is erased here:

https://github.com/vuejs/vue-router-next/blob/096d86498e954345c6bd4d8e82fe54c37d3f869b/src/RouterLink.ts#L140

Is there something blocking the full type being exported?

What does the proposed API look like?

Removing the as unknown as Component.

file path is lost when opening a html file directly in browser

I have the following router...

const routerHistory = createWebHashHistory();

const router = createRouter({
  history: routerHistory,
  routes: [
    { path: "/", component: viewDashboard },
    { path: "/home", redirect: "/" },
    { path: "/params", component: viewParameters },
    // ....
  ],
  scrollBehavior(to, from, savedPosition) {
    return { x: 0, y: 0 };
  },
});

It works well if served from a http-serve or web server or whatever - but if the dist file is opened as a file:///...path...to../index.html directly in the browser, the route automatically changes to file:///#/ losing the whole file path and name.

tag attribute on <router-link> does not seem to be working / a is always used

Using router alpha.4 and vue alpha.10

<router-link to="/" tag="li">dashboard</router-link>

gives me (notice the tag attribute in the final html)

<a aria-current="page" href="/#/" tag="li" class="router-link-active router-link-exact-active">dashboard</a>

v-slot not helping either (taken directly from vue router 3 api docs)...

<router-link
  to="/"
  v-slot="{ href, route, navigate, isActive, isExactActive }"
>
  <li
    :class="[isActive && 'router-link-active', isExactActive && 'router-link-exact-active']"
  >
    <a :href="href" @click="navigate">{{ route.fullPath }}</a>
  </li>
</router-link>

I get the following

<a aria-current="page" href="/#/" class="router-link-active router-link-exact-active">
   <li class="router-link-active router-link-exact-active">
      <a href="/#/">/</a>
   </li>
</a>

Go back

What problem does this feature solve?

Can i go back programmatically in history like in react-router?

What does the proposed API look like?

.

Add query parameter mode for routers. Based on history mode. Use query parameter matching instead of dynamic route matching.

Add query parameter mode for routers. Based on history mode. Use query parameter matching instead of dynamic route matching.

What problem does this feature solve?

The use of query parameter mode does not require the server to set up route fallback.

If you don't want a very ugly hash, we can use the history mode of routing, which makes full use of the history.pushState API to complete the URL jump without reloading the page.

When you use the history mode, the URL is like a normal url.

I encountered the following problem using history mode.

However, to use this mode, you need to configure the background support.
If the background is not properly configured, when the user directly accesses in the browser, it will return 404.

I personally don't like the dynamic route matching mode, I like the query parameter matching mode.

E.g

https://nodejs.org/en/?foo=bar&baz=123



https://nodejs.org/en/?qqq=1&www=111

https://translate.google.cn/#view=home&op=translate&sl=zh-CN&tl=en

What does the proposed API look like?

const changelistener = () => {
  let hashparams = gethashparams();
  let searchparams = getsearchparams();
  console.log("hash params", hashparams);
  console.log("search params", searchparams);
};

window.addEventListener("popstate", changelistener);

window.addEventListener("hashchange", changelistener);

function assign(opt) {
  let params = getsearchparams();
  setsearchparams(Object.assign(params,opt));
}

function replace(opt) {
  setsearchparams(opt);
}

replace({ qqq: 1 });

assign({ www: 111 });

assign({ foo: "bar" });

The query parameters can be obtained from location.search or location.hash.

function gethashparams() {
  return location.hash&& Object.fromEntries(new URLSearchParams(location.hash.slice(1)));
}
function getsearchparams() {
  return location.search&& Object.fromEntries(new URL(location.href).searchParams);
}

The query parameters can be modified in the following ways.

function setsearchparams(opt) {
  let url = new URL(location.href);

  url.search = String(new URLSearchParams({ ...opt }));
  history.pushState(null, null, url.href);

  window.dispatchEvent(new Event("popstate"));
}

function sethashparams(opt) {
  let url = new URL(location.href);

  url.hash = String(new URLSearchParams({ ...opt }));
  history.pushState(null, null, url.href);

  window.dispatchEvent(new Event("hashchange"));
}

examples

location.href

"https://jspang.com/detailed?id=54"

getsearchparams()

{id: "54"}

examples:

location.href

"https://translate.google.cn/#view=home&op=translate&sl=zh-CN&tl=en"


gethashparams()

{view: "home", op: "translate", sl: "zh-CN", tl: "en"}

The route matching method example is as follows:

const routes = [
  {
    component: Home,

    filter({ hash, search }) {
      return hash ==='' &&search===''
    },
  },
  {
    component: Foo,

    filter({ hash, search }) {
      return search.foo === "foo1";
    },
  },
  {
    component: Bar,

    filter({ hash, search }) {
      return hash.bar === "bar1";
    },
  },

  {
    component: NotFound,

    filter() {
      return true;
    },
  },
];

const router = new VueParamsRouter({
  routes,
});

It should be supported in routing for uncertain running path after packaging

What problem does this feature solve?

If I am a developer and don't know which secondary or even tertiary directory the O & M personnel will deploy to, then I will not be able to set the base path in the createwebhashhistory() method, so I need to communicate the location of the project package with the O & M personnel when I pack, and when I deploy to different environments and paths, the modification of the base path will It will make me confused.

What does the proposed API look like?

I hope vue-router can help me get the base path automatically

isActive not working as expected with v-slot API

Reproduction

https://github.com/jakedohm/router-link-slot-bug-reproduction

Expectation

When I use the v-slot API on a router-link, I'm able to use the isActive property to set classes on the link, like so:

<router-link
  v-slot="{ isActive }"
  :class="[isActive ? 'bg-red' : 'bg-blue']"
  active-class="underline"
  to="/"
  >Home</router-link
>

What's really happening

The isActive property doesn't appear to be set on initial render, causing the bg-blue class to always be set, even if that link is active. Vue throws this warning:
Screenshot 2020-05-01 09 06 10

RouterLink isActive class not working when adding custom class attr.

When a route is active, RouterLink currently does not add router-link-active class when a custom class attribute is provided.

Using JSX

<Link class="nav-item" to="route" /> 

renders

<a class="nav-item" href="/route" />

expected would be

<a class="nav-item router-link-active" href="/route" />

Why `router-view` And `RouterView`

Why There Are Two Ways To Implement Router View. router-view Do Not Require A Import But RouterView Required A Import And Specification In Components

router-next does not like base with trailing slash

A reasonable setup for vue-cli with vue-next (and router) would look like this:

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

Here BASE_URL defaults to /.

In the older router there exists logic to strip the trailing slash:

https://github.com/vuejs/vue-router/blob/fc42d9cf8e1d381b885c9af37003198dce6f1161/src/history/base.js#L213-L231

This is probably gone in router-next. Therefore,

createWebHistory("/")

causes the router to attempt to pushState(.., "//"), resulting in SecurityError: The operation is insecure.

vue-router 4.0.0-alpha.5

No exported member 'RouteConfig'

Version

4.0.0-alpha.12

Reproduction link

https://codesandbox.io/s/vue-router-v4-reproduction-x9xb4?file=/main.ts

Steps to reproduce

Follow the guidelines for starting a new Vue 3 project, and include vue-router (updating to next)

What is expected?

The standard new project to build

What is actually happening?

typescript compiling fails


If RouteConfig is no longer there, should it be mentioned somewhere? And what would the path be for the vue-cli-plugin-vue-next to be able to scaffold the starter project successfully with typescript?

what version should be used by jsdelivr

Is there a way to try this directly in html?

I've tried by adding <script src="//cdn.jsdelivr.net/npm/@posva/[email protected]"></script> but I get the error: "Uncaught SyntaxError: Cannot use import statement outside a module" if I add type="module" to the script tag, then I get a different error: "Uncaught TypeError: Failed to resolve module specifier "vue". Relative references must start with either "/", "./", or "../"."

I'm guessing this isn't bundled to be used directly in html?

Typing issue with 4.0.0-alpha.4

It looks like there is a typing issue using the lastest release.
dist/vue-router.d.ts has the following declarations:

export declare function useRoute(): import("./types").RouteLocationNormalizedResolved;

export declare function useRouter(): import("./router").Router;

but types and router are not in the directory, which leads to the following compilation errors:

369:44 Cannot find module './types'.
    367 | declare type UseLinkOptions = VueUseOptions<LinkProps>;
    368 |
  > 369 | export declare function useRoute(): import("./types").RouteLocationNormalizedResolved;
        |                                            ^
    370 |
    371 | export declare function useRouter(): import("./router").Router;
    372 |
ERROR in /Users/ced-pro/vue-router-test/node_modules/vue-router/dist/vue-router.d.ts(371,45):
371:45 Cannot find module './router'.
    369 | export declare function useRoute(): import("./types").RouteLocationNormalizedResolved;
    370 |
  > 371 | export declare function useRouter(): import("./router").Router;
        |                                             ^
    372 |
    373 | export declare function useView(options: UseViewOptions): (attrs: {
    374 |     [key: string]: unknown;
ERROR in /Users/ced-pro/vue-router-test/node_modules/vue-router/dist/vue-router.d.ts(375,41):
375:41 Namespace '"/Users/ced-pro/vue-router-test/node_modules/vue/dist/vue"' has no exported member 'RendererNode'.
    373 | export declare function useView(options: UseViewOptions): (attrs: {
    374 |     [key: string]: unknown;
  > 375 | }) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement> | null;
        |                                         ^
    376 |
    377 | declare type UseViewOptions = VueUseOptions<ViewProps>;
    378 |
ERROR in /Users/ced-pro/vue-router-test/node_modules/vue-router/dist/vue-router.d.ts(375,69):
375:69 Namespace '"/Users/ced-pro/vue-router-test/node_modules/vue/dist/vue"' has no exported member 'RendererElement'.
    373 | export declare function useView(options: UseViewOptions): (attrs: {
    374 |     [key: string]: unknown;
  > 375 | }) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement> | null;
        |                                                                     ^
    376 |
    377 | declare type UseViewOptions = VueUseOptions<ViewProps>;
    378 |
ERROR in /Users/ced-pro/vue-router-test/node_modules/vue-router/dist/vue-router.d.ts(381,49):
381:49 Namespace '"/Users/ced-pro/vue-router-test/node_modules/vue/dist/vue"' has no exported member 'RendererNode'.
    379 | export declare const View: new () => ComponentPublicInstance<{
    380 |     name: string;
  > 381 | } & {}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement> | null, unknown, {}, {}, import("vue").VNodeProps & {} & {
        |                                                 ^
    382 |     name?: string | undefined;
    383 | }>;
    384 |
ERROR in /Users/ced-pro/vue-router-test/node_modules/vue-router/dist/vue-router.d.ts(381,77):
381:77 Namespace '"/Users/ced-pro/vue-router-test/node_modules/vue/dist/vue"' has no exported member 'RendererElement'.
    379 | export declare const View: new () => ComponentPublicInstance<{
    380 |     name: string;
  > 381 | } & {}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement> | null, unknown, {}, {}, import("vue").VNodeProps & {} & {
        |                                                                             ^
    382 |     name?: string | undefined;
    383 | }>;

I guess the last errors will be fixed with your commit in vue-next when alpha.11 will be out, but I'm not sure about the first two.

Cannot read property of listen of undefined

Version

4.0.0-alpha.12

Reproduction link

https://codesandbox.io/s/vue-router-v4-reproduction-l5fzm?file=/index.html

Steps to reproduce

How to Reproduce:
When the developer omits the history property when instantiating createRouter function, the above error is shown.

const router = createRouter({
  routes: [{
    path: "/",
    component: { template: "<div>Home</div>"}, 
  }, {
    path: "/path2",
    component: { template: "<div>path</div>"}
  }]
})

What is expected?

Error should indicate that the history method is a required field (and suggest one of...)

However, the docs indicate the for client side applications, the default is only createWebHistory (unless this is SSR).

What is actually happening?

Uncaught TypeError: Cannot read property 'listen' of undefined
at createRouter (vue-router.esm-bundler.js:2269)
at main.js:16
createRouter @ vue-router.esm-bundler.js:2269
(anonymous) @ main.js:16


How to resolve:

Include history property within createRouter options.

const routerHistory = createWebHistory()
const router = createRouter({
  history: routerHistory,
  routes: [{
    path: "/",
    component: { template: "<div>Home</div>"}, 
  }, {
    path: "/cv",
    component: { template: "<div>CV</div>"}
  }]
})

Suggestion:

The error log should include an improved message that the history field should be createWebHistory() or others that are supported. (Can not suggest as it is not included in tests)

May wish to include that in the docs.

"Failed to resolve component: router-view" - compatibility with Vite

Trying out Vite (a week old tool for building buildless Vue components) took me to Vue 3 beta and vue-router-next.

I am currently facing this:

Failed to resolve component: router-view

Not sure whether it's due to Vue 3 beta or something Vite specific. Decided to open this issue in order to gather discussions, if others are facing something similar.

resolve fails

My code base is at: https://github.com/akauppi/GroundLevel-es6-firebase-web/tree/vite-maybe

Use the vite-maybe branch.

Error from RouterView: matched undefined

Version

3.0.0-beta.7

Reproduction link

https://github.com/chenxeed/vue3-boilerplate

Screenshot from 2020-05-04 13-59-44

Steps to reproduce

  1. Install the package with yarn install
  2. Run the app locally with yarn serve
  3. BOOM, app not running

What is expected?

The app should run as usual and the page rendered

What is actually happening?

Page not rendered, and there's an error from the console.

TypeError: Cannot read property '0' of undefined


It was fine when I was using Vue beta-3. Perhaps something breaks between beta 4-7.

`useRoute` and `useRouter` return undefined if called after an `await`

In the following situation, useRoute will work because it's called before the await, while useRouter will not work because it's called after the await.

async setup(){
  const postsUrl = "http://localhost:3000/posts"
  const route = useRoute();
  const response = await axios.get(`${postsUrl}/${route.params.id}`);
  const router = useRouter()
}

If we change the order, then useRouter will work.

async setup(){
  const postsUrl = "http://localhost:3000/posts"
  const route = useRoute();
  const router = useRouter()
  const response = await axios.get(`${postsUrl}/${route.params.id}`);
}

redirect route '/' to '/home',click browser 'goback' button,something is wrong

[email protected]
vue-router@^4.0.0-alpha.7

here is my routes

export const router = createRouter({
  history: routerHistory,
  routes: [
    {
      path: '/',
      redirect: '/home',
    },
    {
      path: '/home',
      component: Home,
    },
    {
      path: '/detail',
      component: DetailPage,
    },
  ],
})

i can enter my app on localhost:8080, it can redirect to localhost:8080/home; it works.
But,when i use router.push({ path: '/detail'}) in component Home, it goes to localhost:8080/detail, then, click the click browser 'goback' button, it goes to localhost:8080, it never go to localhost:8080/home

support list all dynamically added routes

What problem does this feature solve?

in the stable vue-router version there is no official function to get dynamically added routes initiated routes as the total routes of the application. is this supported in this version ?

What does the proposed API look like?

$router.getAllRoutes() // will fetch all initiated routes  and dynamically added routes

New project 'Cannot read property '0' of undefined'

Version

4.0.0-alpha.9

Reproduction link

https://github.com/FairyEver/vue-next-demo

Steps to reproduce

yarn
yarn serve

What is expected?

Running the project normally

What is actually happening?

After running the project, visit http://localhost:8080 in the browser
TypeError: Cannot read property '0' of undefined


I used the following command to create a new project without any other changes, But it's not working properly

vue create demo
...
vue add vue-next

Params from the current location are not copied to the target location

I've noticed that there is a todo to merge the params from the current location into the target location.

https://github.com/vuejs/vue-router-next/blob/9697134c05f0f4c6fde48a773880946074e95666/src/matcher/index.ts#L201

However, this is not the only place where you'd need to merge route params. When there is a redirect in a route, it only uses the params from the redirectedFrom location or the targetLocation. But instead, the params from targetLocation should be merged into the redirectedFrom location if it exists.

Here's what I did to get most of the old Vue Router 3 behavior back: https://github.com/janispritzkau/vue-router-next/commit/bc5d568d5412380f226e518ae6d50e14e079d2b1

I'm not sure what is meant with Should this be done by name. in the comment above.

Why `router-view` And `RouterView`

Why There Are Two Ways To Implement Router View. router-view Do Not Require A Import But RouterView Required A Import And Specification In Components

vue-router-next not support router.back ?

What problem does this feature solve?

I'm upgrading the project vue3,before that, I can use $router.back() , but now it will error router.go is not a function

 const router = useRouter();
 const back = () => {
      router.back();
   };
return { back };

What does the proposed API look like?

useRouter?

路由设置:打包base路由不自动获取(打包后二级目录无法正常访问)

What problem does this feature solve?

当在创建路由的时候直接使用createWbeHashHistory()的时候,将打包的工程进行代理访问后,如果不在/根路径的时候会自动访问到根下,并且会导致其他资源访问失败(如:访问http://localhost:8080/assemble/#/ 会自动变成http://localhost:8080/#/)。可以解决打包后访问二级目录工程时候路由问题。

What does the proposed API look like?

hash模式的时候在vue-router.cjs.js中,第200行的normalizeBase方法中添加如果没有传递默认base或者html中没有默认base标签时,获取localtion.pathname作为base路由

 base = (baseEl && baseEl.getAttribute('href')) || localtion.pathname; // 第205行

在history模式时将在482行的方法createWebHistory中添加强制校验至少需要传递base参数或者标签

    if (!base && !document.querySelector('base')) return createRouterError(**, **);

Cannot read property of listen of undefined

Error:

Uncaught TypeError: Cannot read property 'listen' of undefined
at createRouter (vue-router.esm-bundler.js:2269)
at main.js:16
createRouter @ vue-router.esm-bundler.js:2269
(anonymous) @ main.js:16

How to Reproduce:

When the developer omits the history property when instantiating createRouter function, the above error is shown.

const router = createRouter({
  routes: [{
    path: "/",
    component: { template: "<div>Home</div>"}, 
  }, {
    path: "/path2",
    component: { template: "<div>path</div>"}
  }]
})

How to resolve

const routerHistory = createWebHistory()
const router = createRouter({
  history: routerHistory,
  routes: [{
    path: "/",
    component: { template: "<div>Home</div>"}, 
  }, {
    path: "/cv",
    component: { template: "<div>CV</div>"}
  }]
})

How to improve

The error log should include an improved message that the history field should be createWebHistory() or others that are supported. (Can not suggest as it is not included in tests)

May wish to include that in the docs.

Require "redirect" param when init a RouteRecordRaw

Version

4.0.0-alpha.12

Reproduction link

https://jsfiddle.net/rdshe206/

Steps to reproduce

Nothing. It is an error from es-linter.

Property 'redirect' is missing in type '{ path: string; component: typeof import("[PATH]/node_modules/vue/dist/vue"); }' but req...
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import Home from '../views/Home.vue';
const routes:RouteRecordRaw[] = [
        // I GOT THE ERROR HERE
	{
		path: '/',
		name: 'home',
		component: Home
	}
];
const router = createRouter({
	history: createWebHistory(process.env.BASE_URL),
	routes: routes
});
export default router;

Why redirect is required?

I checked the type and it is

export type RouteRecordRaw =
  | RouteRecordSingleView
  | RouteRecordMultipleViews
  | RouteRecordRedirectRaw

so one of the 3 options. But why it picks the RedirectRaw? it should pick the SingleView right?

My setup

"vue": "^3.0.0-beta.14",
"vue-router": "^4.0.0-alpha.12",
"vuex": "^4.0.0-alpha.2" 

What is expected?

To pick the RouteRecordSingleView

What is actually happening?

It picks RouteRecordRedirectRaw

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.