umi的路由没起作用

新手上路,请多包涵

image.png
这个是文档结构


export default {
    treeShaking: true,
    routes: [
        {
            path: '/',
            component: '../layouts/index',
            routes: [
                {path: '/', component: '../pages/index'},
                {path: '/time', component: '../pages/Time1'}
            ]
        }
    ],
    plugins: [
        // ref: https://umijs.org/plugin/umi-plugin-react.html
        ['umi-plugin-react', {
            antd: true,
            dva: true,
            dynamicImport: {webpackChunkName: true},
            title: 'ashe-portal',
            dll: true,
            locale: {
                enable: true,
                default: 'en-US',
            },
            routes: {
                exclude: [
                    /models\//,
                    /services\//,
                    /model\.(t|j)sx?$/,
                    /service\.(t|j)sx?$/,
                    /components\//,
                ],
            },
        }],
    ],
}

这是路由配置的文件
然后访问的时候每次都会报404
image.png
各位大佬帮忙看看这个问题,谢谢了

阅读 5.1k
1 个回答

component 是相对于src/pages目录的
去掉个点就行了
{path:'/',component:'./pages/index},
{path:'/time',component:'./pages/Time1'}

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题