vue-webpack使用路由

1.在src-router-index.js中寫入路由路徑

export default new Router({
    routes: [{
            path: "/",
            name: "Login",
            component: Login
        },
        {
            path: "/Index",
            name: "Index",
            component: Index
        }
    ]
});

2.然後在頭部引入模塊

import Login from "@/components/Login";
import Index from "@/components/Index";

3.寫一個路由出口(一般在src-app.vue中)

<template>
  <div id="app">
    <router-view />
  </div>
</template>

4.在使用時進行路由跳轉

this.$router.push("/Index");

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章