VueJs到/或家的路线

时间:2019-01-17 15:47:37

标签: vue.js routing routes

我的路由有问题。

当我进行构建时, 而且当我继续前进**** / dist /时,我在家中的路由不起作用。

但是页面只有导航栏为空白。

我想进入“登录”页面。

谢谢您的未来帮助:)

这是我的App.vue

<template>
  <div id="app" >
    <!-- class="container"-->
    <b-container fluid>
      <navbar></navbar>
      <router-view/>
    </b-container>
  </div>
</template>

<script>
    import Navbar from './components/navbar/Navbar'
export default {
  name: 'App',
    methods: {
    },
    components: {
        Navbar
    }
}
</script>
<style>

</style>

这是我的路由器

    {
        path: '/',
        name: 'home',
        component: Login,
    },
    {
        path: '/login',
        name: 'login',
        component: Login,
        meta: { 
            guest: true
        }
    },
    {
        path: '/dashboard',
        name: 'userboard',
        component: UserBoard,
        meta: { 
            requiresAuth: true
        }
    },
    {
        path: '/myBooked',
        name: 'Booked',
        component: Booked,
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/admin',
        name: 'admin',
        component: Admin,
        meta: { 
            requiresAuth: true,
            is_admin : true
        }
    },

编辑2019-101-18:@Sajib Khan

在main.js中(默认),带有:

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

路由器:

import Vue from 'vue'
import Router from 'vue-router'
import Booked from '@/components/Booked'
import Login from '@/components/Login'
import UserBoard from '@/components/UserBoard'
import Admin from '@/components/Admin'

Vue.use(Router)

let router = new Router({
    //base: '/dist',
    mode: 'history',
  routes: [
    {
        path: '/',
        name: 'home',
        component: Login,
    },
    {
        path: '/login',
        name: 'login',
        component: Login,
        meta: { 
            guest: true
        }
    },
    {
        path: '/dashboard',
        name: 'userboard',
        component: UserBoard,
        meta: { 
            requiresAuth: true
        }
    },
    {
        path: '/myBooked',
        name: 'Booked',
        component: Booked,
        meta: {
            requiresAuth: true
        }
    },
    {
        path: '/admin',
        name: 'admin',
        component: Admin,
        meta: { 
            requiresAuth: true,
            is_admin : true
        }
    },
  ]
})

0 个答案:

没有答案