search

Home  >  Q&A  >  body text

javascript - How to add a new page after vue-cli is built

I just built the structure of vue-cli

This page has come out. If I want to continue to add several components, how should I edit it? I have no idea. I’m not very familiar with router yet, please give me some advice

黄舟黄舟2787 days ago546

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 13:45:56

    Use vue-router to configure routing and inject it in the vue root instance

    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,
    })

    That’s about it. Use <router-link to="/play"></router-link> for the link.
    It is recommended to learn from the documentation

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-16 13:45:56

    http://router.vuejs.org/zh-cn...
    Reference documentation. .
    Configure routing

    reply
    0
  • Cancelreply