View-router

インストール。通常 module システムの中で使うことになると思うので、use で宣言してから使用すること。

router/index.js etc...
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

routing を設定する。

router/index.js etc...
const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/nologin',
    name: 'Nologin',
    component: NoLogin
  },
  {
    path: '/index',
    name: 'Index',
    component: Index,
  }
]

// name をつけておくと、
// this.$router.push({name: 'route-name'}) で移動できて便利

module を出力する。

router を注入

注入して入れば、router-view コンポーネントして自動的に使える模様。

Last updated