【发布时间】:2021-05-02 13:45:47
【问题描述】:
伙计们,所以基本上我有我的 routes.js 文件,显然我的路由在其中,但我正在尝试添加另一个路由,如果用户尝试访问不在我的应用程序上的路由,它将重定向到 404 页面
{ path: '*', component: require('./components/NotFound.vue') }
这是我的 route.js 文件
import VueRouter from 'vue-router'
Vue.use(VueRouter)
import dashboard from './components/Dashboard'
import profile from './components/Profile'
import user from './components/Users'
import unauthorized from './components/Unauthorized'
/**
*
*
better run npm run watch or your routes will not work
also the main page is the one with the id="app"
dont forget to add a link in that main page to app.js
<script src="{{ asset('js/app.js') }}" defer></script>
*
*
*/
let routes = [
{
path: '/dashboard',
component: dashboard
},
{
path: '/profile',
component: profile
},
{
path: '/users',
component: user
},
{
path: '/unauthorized',
component: unauthorized,
name: unauthorized
},
{
path: '*',
component: 404
}
]
export default new VueRouter({
mode: 'history',
routes
})
这就是我写的,它给了我错误并且不起作用,请需要帮助
谢谢
【问题讨论】: