import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../components/HelloWorld.vue' //这是你的首页组件
Vue.use(VueRouter)
const routes = [
{
path:'/',
redirect:'',
component:Index
}
]
const router = new VueRouter({
mode:'history',
routes
})
export default router
3.在main.js引入你的router配置文件
import Vue from 'vue'
import App from './App.vue'
import router from './router/index'
Vue.config.productionTip = false
new Vue({
router,
render: h => h(App),
}).$mount('#app')