如题,我umi3发布后,我尝试更新,并打算试一试约定式路由,改成配置时路由后,页面变为无导航模式,可是配置菜单却让我很头疼,我按照文档提示(@umijs/plugin-layout)打算找出点方法,于是找到了这样一段代码
export const routes= [
{
path: '/welcome',
component: 'IndexPage',
menu: {
name: '欢迎', // 兼容此写法
icon: 'testicon',
},
layout:{
hideNav: true,
},
access: 'canRead',
}
]
我尝试按照这样去在config/router.js中配置菜单,却什么也不生效。是文档不够清晰,还是这里有问题呢?
按照文档提示,config中已经配置过layout相关option。
请指条明路。
提供下复现步骤,期望结果,实际结果?
因为没有在ant design pro中用过约定式路由,那天尝试换了一下,具体操作步骤如下
defineConfig中加入layout配置项config/router.js文件夹,加入router看到umi3更新日志中有提到约定式路由,想尝尝新鲜,可不能很顺利的将菜单、路由、不同布局结合起来。期望有一详细文档能协助在配置式路由和约定式路由之间无缝转换
21天也是醉了。
我理解的意思是使用@umijs/plugin-layout后,在.umirc.ts或config/config.js中添加
export default defineConfig({
layout: {},
...
});
然后左侧菜单怎么出现?
src/pages/目录生成左侧菜单,请问可以吗?期望结果
@umijs/plugin-layout后,可以根据src/pages/目录生成左侧菜单实际结果
以下碎碎念(吃了猪肉又觉得肉少)
文档
清晰的文档会增加开源团队的时间成本! 但:
(使用者 x 阅读文档时间) > (开源团队 x 完善文档时间)
文档描述不到的功能,是不是等于没有,至少大大打折!
(至少确保大版本是可以好好撸的)
|
|
|
最后肉是香的,希望在发布4.0时候,3.0文档是完整的,开源不易,加油~ @sorrycc
俺也一样 😶
感觉 umi3 就是个半成品 造成这个认知 可能 就是 文档跑不通的原因吧。
这个umi3文档,我已经醉了。
就拿config router这一件事来说,我能找到的官方文档分两部分。
https://umijs.org/docs/routing
https://umijs.org/config#routes
但是写的极其宽泛,杂乱无比,毫无条理。没一个地方解释name title之间的关系(文档里根本就没有name)。后者还有一个跳往“路由配置章节”的链接也挂了。。。。。。
一直以为是自己白痴不会,没想到你们也一样啊。
如题,我umi3发布后,我尝试更新,并打算试一试约定式路由,改成配置时路由后,页面变为无导航模式,可是配置菜单却让我很头疼,我按照文档提示(@umijs/plugin-layout)打算找出点方法,于是找到了这样一段代码
export const routes= [ { path: '/welcome', component: 'IndexPage', menu: { name: '欢迎', // 兼容此写法 icon: 'testicon', }, layout:{ hideNav: true, }, access: 'canRead', } ]我尝试按照这样去在
config/router.js中配置菜单,却什么也不生效。是文档不够清晰,还是这里有问题呢?
按照文档提示,config中已经配置过layout相关option。
请指条明路。
敢问你们 的菜单出来了吗
有解决了的吗
怎么解决
umirc.ts
export default defineConfig({
layout: {
name: ' ',
theme: 'pro',
locale: true,
},
routes: [
{
path: '/login',
layout: false,
component: '@/pages/login',
},
//......
],
})
路由类似这样配置就可以显示了
config.ts配置layout
routes: [
{
path: '/user',
layout: false,
routes: [
{
name: 'login',
path: '/user/login',
component: './User/login',
},
],
},
{
path: '/welcome',
name: 'welcome',
icon: 'smile',
component: './Welcome',
},
{
path: '/admin',
name: 'admin',
icon: 'TeamOutlined',
access: 'canAdmin',
// component: './Admin',
routes: [
{
path: '/admin/user',
name: 'user',
component: './UserList',
},
{
path: '/admin/user/detail/:id',
name: 'userDetail',
hideInMenu: true,
component: './UserDetail',
},
{
path: '/admin/profile',
name: 'profile',
component: './ProfileList',
},
{
path: '/admin/profile/add',
name: 'addProfile',
hideInMenu: true,
component: './AddProfile',
},
{
path: '/admin/profile/detail/:id',
name: 'profileDetail',
hideInMenu: true,
component: './ProfileDetail',
},
],
},
]
It's inactive above 3 months, feel free to reopen if still have problems.
Most helpful comment
21天也是醉了。
我理解的意思是使用
@umijs/plugin-layout后,在.umirc.ts或config/config.js中添加然后左侧菜单怎么出现?
src/pages/目录生成左侧菜单,请问可以吗?期望结果
@umijs/plugin-layout后,可以根据src/pages/目录生成左侧菜单实际结果
以下碎碎念(吃了猪肉又觉得肉少)
文档
清晰的文档会增加开源团队的时间成本! 但:
文档描述不到的功能,是不是等于没有,至少大大打折!
(至少确保大版本是可以好好撸的)
|
|
|
最后肉是香的,希望在发布4.0时候,3.0文档是完整的,开源不易,加油~ @sorrycc