rv54ntjwfm3ug8
V2EX  ›  Angular

Angular 的 API 请求全放在一个服务里还是分开不同服务比较好?全放一起感觉文件太长了。另外服务和 component 放一起会不会看起来更整齐一些?官方好像不是这么做

  •  
  •   rv54ntjwfm3ug8 · Apr 14, 2022 via iPhone · 2616 views
    This topic created in 1501 days ago, the information mentioned may be changed or developed.
    4 replies    2022-04-15 14:34:51 +08:00
    ktqFDx9m2Bvfq3y4
        1
    ktqFDx9m2Bvfq3y4  
       Apr 14, 2022 via iPhone
    分开,就像后端一样。
    nzbin
        2
    nzbin  
       Apr 14, 2022
    不能一概而论,一般接口服务放在组件目录就行,有时候可能还要在模块目录创建
    linkopeneyes
        3
    linkopeneyes  
       Apr 14, 2022
    我们一般是跟着后端路由走,一个路由一个服务,然后写一个基础类把增删改查封装在里面,然后服务继承一下传一下路径
    meshell
        4
    meshell  
       Apr 15, 2022
    一开始我放一起了,后来我按模块分开来了。一个文件接口多了太费眼了。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3894 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 466ea39e · 81ms · UTC 04:24 · PVG 12:24 · LAX 21:24 · JFK 00:24
    ♥ Do have faith in what you're doing.