V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
whx20202
V2EX  ›  问与答

请问前端本地测试代码, API 这块怎么处理的?

  •  
  •   whx20202 · Jan 23, 2018 · 1915 views
    This topic created in 3016 days ago, the information mentioned may be changed or developed.

    我前端 js 里面,是直接写的,比如: /api/items/1 感觉在本机上测试代码很麻烦啊,每次都得在前面加 ip,(跨域倒不是问题,chrome 有个插件)

    代码写完了,提交到 git 上的时候还得改回去,不胜其烦

    最近刚在写前端,不清楚正确的姿势是什么样子的

    2 replies    2018-01-23 21:24:54 +08:00
    szdubinbin
        1
    szdubinbin  
       Jan 23, 2018
    封装 ajax,把域名 /ip 先封装
    panpanpan
        2
    panpanpan  
       Jan 23, 2018 via iPhone   ❤️ 1
    本地搭一个 nginx,根据 url 来转发
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3745 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:41 · PVG 12:41 · LAX 21:41 · JFK 00:41
    ♥ Do have faith in what you're doing.