vue-cli搭建后如何加入新页面

我刚搭建好了vue-cli的结构

https://img1.mukewang.com/5c0b6d090001584b06490543.jpg

这个页面已经出来了,如果我想往下继续添加几个组件应该怎么编辑,本人对router还不是特别熟,求指教

紫衣仙女
浏览 1267回答 1
1回答

白衣染霜花

使用vue-router配置路由 在vue根实例中注入import Vue from 'vue'import VueRouter from 'vue-router'import topNav from '../components/topNav'import mine from '../components/mine'import searchPage from '../components/searchPage'import searchResult from '../components/searchResult'import playPage from '../components/playPage'import playbottom from '../components/playbottom'import latestPlay from '../components/latestPlay'Vue.use(VueRouter)const router = new VueRouter({&nbsp; &nbsp; routes: [&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path: '/',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component: mine&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path: '/mine',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component: mine&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path: '/mine/searchPage',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component: searchPage&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path: '/mine/searchPage/searchResult',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component: searchResult&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path: '/playPage',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component: playPage&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path: '/latestPlay',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; component: latestPlay&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; ]})export default routerimport router from '../router'var app = new Vue({&nbsp; &nbsp; el: "#app1",&nbsp; &nbsp; router,&nbsp; &nbsp; store: vuex_store,})大概就是这样 链接用<router-link to="/play"></router-link>这样&nbsp;建议还是通过文档学习
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript