whx20202
V2EX  ›  问与答

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

  •  
  •   whx20202 · Jan 23, 2018 · 1935 views
    This topic created in 3030 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   ·   5736 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 06:00 · PVG 14:00 · LAX 23:00 · JFK 02:00
    ♥ Do have faith in what you're doing.