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

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

  •  
  •   rv54ntjwfm3ug8 · 2022-04-18 19:13:51 +08:00 · 1214 次点击
    这是一个创建于 731 天前的主题,其中的信息可能已经有所发展或是发生改变。

    本来应该发 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-04-18 19:17:42 +08:00
    第二种,结构层次最舒服
    Chism
        2
    Chism  
       2022-04-18 21:22:20 +08:00 via Android
    react 和 vue 我会,这样 css 等自用的文件避免跟其它混淆,ag 没用过。。
    wunonglin
        3
    wunonglin  
       2022-04-18 21:58:11 +08:00
    2.每个组件一个目录,或者每个模块一个目录,针对 ng
    susan0007
        4
    susan0007  
       2022-04-19 17:15:07 +08:00
    我用 react 会选择第一种,因为只有一个 tsx 文件。
    对于组件文件数量大于 2 的,我会选第二种。
    sjhhjx0122
        5
    sjhhjx0122  
       2022-04-20 16:38:31 +08:00
    第二种啊
    renhou
        6
    renhou  
       2022-04-28 11:04:18 +08:00
    比较常用第二种
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1059 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 19:12 · PVG 03:12 · LAX 12:12 · JFK 15:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.