在動態完全加載路由器路由的安全性方面,最佳實踐是什么?
- 從后端檢索所有路由并使用 router.addRoutes 而不在客戶端對其進行硬編碼?
- 創建正常路由并過濾它們?(這難道不會在客戶端仍然有整個路由器路由可用于惡意訪問嗎?)
我在這里讀到1. 是建議的方式,但我不明白在映射組件方面需要做什么。您不能 JSON.stringify 路由的組件屬性,因為它是一個函式。讓我們使用一個路由器片段示例:
{
path: '/employees',
component: () => import('@/layout'),
redirect: '/employees/master',
name: 'Employees',
alwaysShow: true,
meta: {
title: 'Employees',
icon: 'user',
roles: ['Admin'] // you can set roles in root nav
},
children: [
{
path: 'master',
component: () => import('@/views/employees/master.vue'),
name: 'Master',
children: [
{
path: '',
name: 'MasterIndex',
component: () => import('@/views/employees/views/index.vue'),
meta: { title: 'Master', noCache: true, icon: 'user' }
},
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
uj5u.com熱心網友回復:
沒關系,在這里找到解決方案。提供更多背景關系:
將組件的字串部分保存到映射中,取回字串并傳遞給在客戶端創建函式。然后將函式附加到路由。我沒有立即想到將關注點分開而不是完整地處理組件。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/442953.html
標籤:sql Vue.js Vue组件 Vue路由器 字符串化
上一篇:使用SFC在Vue中編輯表單
