V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
rv54ntjwfm3ug8
V2EX  ›  前端开发

你们习惯给每个 component 都建一个独立的目录吗?为什么?

  •  
  •   rv54ntjwfm3ug8 · 2022 年 4 月 18 日 · 1733 次点击
    这是一个创建于 1364 天前的主题,其中的信息可能已经有所发展或是发生改变。

    本来应该发 Angular 节点的,但那里太冷清了就挪过来了

    1 )

    .\layout\layout.component.[css|ts|html|spec.ts]
    .\layout\side-nav.component.[css|ts|html|spec.ts]
    .\layout\top-bar.component.[css|ts|html|spec.ts]
    

    还是 2 )

    .\layout\layout.component.[css|ts|html|spec.ts]
    .\layout\side-nav\side-nav.component.[css|ts|html|spec.ts]
    .\layout\top-bar\top-bar.component.[css|ts|html|spec.ts]
    

    又或是 3 ):

    .\layout\layout\layout.component.[css|ts|html|spec.ts]
    .\layout\side-nav\side-nav.component.[css|ts|html|spec.ts]
    .\layout\top-bar\top-bar.component.[css|ts|html|spec.ts]
    

    或者还有第 4 种?

    6 条回复    2022-04-28 11:04:18 +08:00
    a935855375
        1
    a935855375  
       2022 年 4 月 18 日
    第二种,结构层次最舒服
    Chism
        2
    Chism  
       2022 年 4 月 18 日 via Android
    react 和 vue 我会,这样 css 等自用的文件避免跟其它混淆,ag 没用过。。
    shakaraka
        3
    shakaraka  
    PRO
       2022 年 4 月 18 日
    2.每个组件一个目录,或者每个模块一个目录,针对 ng
    susan0007
        4
    susan0007  
       2022 年 4 月 19 日
    我用 react 会选择第一种,因为只有一个 tsx 文件。
    对于组件文件数量大于 2 的,我会选第二种。
    linkopeneyes
        5
    linkopeneyes  
       2022 年 4 月 20 日
    第二种啊
    renhou
        6
    renhou  
       2022 年 4 月 28 日
    比较常用第二种
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2932 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 13:53 · PVG 21:53 · LAX 05:53 · JFK 08:53
    ♥ Do have faith in what you're doing.