我刚搭建好了vue-cli的结构
这个页面已经出来了,如果我想往下继续添加几个组件应该怎么编辑,本人对router还不是特别熟,求指教
PHP中文网2017-05-16 13:45:56
使用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({
routes: [
{
path: '/',
component: mine
},
{
path: '/mine',
component: mine
},
{
path: '/mine/searchPage',
component: searchPage
},
{
path: '/mine/searchPage/searchResult',
component: searchResult
},
{
path: '/playPage',
component: playPage
},
{
path: '/latestPlay',
component: latestPlay
}
]
})
export default router
import router from '../router'
var app = new Vue({
el: "#app1",
router,
store: vuex_store,
})
大概就是这样 链接用<router-link to="/play"></router-link>这样
建议还是通过文档学习