1、先安装路由
npm install vue-router --save
先引用,然后使用vue-router
import VueRouter from 'vue-router'Vue.use(VueRouter);
3、配置路由
const routes=[{path:'/home',component:Home},{path:'/news',component:News},{path:'*',redirect:'/home'}
];const router = new VueRouter({routes
})new Vue({el:'#app',template: '',components: { App },router,
})render: h => h(App)
111
主页新闻