1、在componets目录下建立Login.vue文件
2、Login.vue文件代码
<template> <div> 登陆组件 </div> </template> <script> export default { } </script> <style scoped> </style>3、增加引用,修改router/index.js文件
import Vue from ‘vue‘ import Router from ‘vue-router‘ import Login from ‘@/components/Login‘ Vue.use(Router) export default new Router({ routes: [ { path: ‘/‘, redirect: ‘/login‘ }, { path: ‘/login‘, name: ‘login‘, component: Login } ] })4、修改App.vue文件
<template> <div id="app"> <router-view></router-view> </div> </template> <script> export default { name: ‘App‘ } </script> <style> </style>
原文:https://www.cnblogs.com/zsnzsn/p/15130422.html