我学习Vue已经两周了,我找不到关于路由安全问题的答案.
当我在Vue中使用元字段和examle中的路由保护程序保护路由时,我想知道客户机可以做些什么来仍然看到组件.
const router = new VueRouter({
routes: [
{
path: '/foo',
component: Foo,
children: [
{
path: 'bar',
component: Bar,
// a meta field
meta: { requiresAuth: true }
}
]
}
]
})
router.beforeEach((to, from, next) => {
// check if authenticated by jwt from store or localstorage
})
路由/foo/bar
由Beforeach钩子和requiresAuth元字段保护.但所有这些代码都在客户端(作为缩小版,但仍然存在).用户可以修改代码并查看组件