javascript - Vue-based spa website, the head and tail of some pages are not fixed
PHPz
PHPz 2017-05-19 10:24:50
0
6
651

Use vue to make a spa website, but some pages do not require headers and tails, or the headers are slightly different. For example, if you click to log in, you do not need a header and navigation bar. What to do at this time? One method is to make the head and tail components into components, and then import these two components into the required pages, but it feels like the amount of code is too much. Is there any other way besides this?

PHPz
PHPz

学习是最好的投资!

reply all (6)
世界只因有你

You can refer to the named view upstairs.
I will send you a router configuration, you will understand it at a glance

routes: [ { path: '/login', name: 'login', meta: {auth: false, title: '登录'}, component: Login }, { path: '/', meta: {title: '首页', active: 1}, component: resolve => require(['../pages/main'], resolve), children: [ erp, crm, ... }]

main.vue

    刘奇

    Write everything in, show it when needed, hide it when not needed?
    But isn’t your own method pretty good? The beginning and end are common, and you can load them based on the routing

      小葫芦

      Is it possible to add a judgment condition and whether to display the head and tail according to the condition? v-if else

        刘奇

        Write multi-level routing.

          Peter_Zhu

          You can consider the named view of vue-route. The specific needs will depend on the business

            某草草

            Follow me if you encounter this problem

              Latest Downloads
              More>
              Web Effects
              Website Source Code
              Website Materials
              Front End Template
              About us Disclaimer Sitemap
              php.cn:Public welfare online PHP training,Help PHP learners grow quickly!