用文件系统自动生成 Vue 路由:routdir

还在手动配置 Vue Router 路由吗?试试 routdir 吧!它利用 Webpack 和文件系统帮你自动生成路由。routdir 的灵感来自 Sapper 和 Next.js,但更轻量。

使用步骤:

  1. 安装:npm i @badrap/routdir

  2. 配置 Webpack,将 ./routes 目录传递给 routdir 函数:

    ```javascript

    import routdir from "@badrap/routdir";

    const routes = routdir(require.context("./routes", true, /.vue$/));

    ```

zip 文件大小:63.42KB