plugin-access icon indicating copy to clipboard operation
plugin-access copied to clipboard

umi 使用 access 配置路由不生效

Open sunbingye opened this issue 5 years ago • 2 comments

//access.js 文件 export default function (initialState) { console.log('initialState', initialState); return { canReadGoods: initialState.roleId === 1 || initialState.roleId === 2 }; } // .umirc.ts 文件 routes: [ { path: '/', component: '@/layouts/index', routes: [ { path: '/', component: '@/pages/index', exact: true }, { path: '/login', component: '@/pages/login', exact: true }, { path: '/goods', component: '@/pages/goods', // exact: true, access: 'canReadGoods', }, ] } ] 已经验证 access 文件返回的 canReadGoods 值是正确的,但是 goods 路径访问没有受到影响。 还有一个问题,如果使用约定式路由,需要对 Goods 路由扩展,即在 goods.js 文件中使用 Goods.access=useAccess().canReadGoods 来进行扩展,但是 hooks 不能在函数组件外部使用,那么该如何配置?

sunbingye avatar Dec 21 '20 16:12 sunbingye

同问这个问题解决了吗

wind4gis avatar Jul 13 '24 08:07 wind4gis

您好,我是孙冰冶。我已经收到您的邮件,谢谢。

sunbingye avatar Jul 13 '24 08:07 sunbingye