OKdevTV Docs
Home OKdevTV
ESC
vue 1 min read 0.9 KB Raw Markdown
On this page (4)

Vue Router

설치

text
npm install vue-router

사용

js
  import VueRouter from 'vue-router';

  // 1. Define route components.
  const Foo = { template: "<div>foo</div>" };
  const Bar = { template: "<div>bar</div>" };

  // 2. Define some routes
  const routes = [
    { path: "/foo", component: Foo },
    { path: "/bar", component: Bar }
  ];

  // 3. Create the router instance and pass the `routes` option
  const router = new VueRouter({
    routes
  });

  const app = new Vue({
    router
  }).$mount("#app");

mode

js
const router = new VueRouter({
  mode: 'history',
  routes: [...]
})

예제