• 请不要在回答技术问题时复制粘贴 AI 生成的内容
asiasky
V2EX  ›  程序员

有没有老哥开发过包含路由的 npm 插件

  •  
  •   asiasky · Apr 2, 2021 · 1462 views
    This topic created in 1951 days ago, the information mentioned may be changed or developed.

    现在 VUE 项目里面有个需求 要把部分功能做成一个插件直接引入 但是这个功能是包含路由的 怎么才能在引用插件的时候将插件中的路由注册到项目的路由上去

    2 replies    2021-04-02 15:48:29 +08:00
    BreadKiller
        1
    BreadKiller  
       Apr 2, 2021   ❤️ 1
    在写插件的时候,传当前项目的 router 实例进去,然后在插件里用 router.addRoutes 注册路由
    asiasky
        2
    asiasky  
    OP
       Apr 2, 2021
    @BreadKiller 好的 我试试 里面一级路由 子路由都有
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3678 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 04:29 · PVG 12:29 · LAX 21:29 · JFK 00:29
    ♥ Do have faith in what you're doing.