如何将ID放在网址中间

时间:2019-04-28 11:43:34

标签: javascript node.js

我已经定义了这样的网址 URLT = URL / id / URL

如何将id的实际值放在“ id”部分(/ id /)中?

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/betka/.local/lib/python2.7/site-packages/phoebe/__init__.py", line 276, in <module>
    from .dependencies.unitsiau2015 import u,c
  File "/home/betka/.local/lib/python2.7/site-packages/phoebe/dependencies/__init__.py", line 1, in <module>
    from . import autofig
  File "/home/betka/.local/lib/python2.7/site-packages/phoebe/dependencies/autofig/__init__.py", line 17, in <module>
    from .call import Plot, Mesh
  File "/home/betka/.local/lib/python2.7/site-packages/phoebe/dependencies/autofig/call.py", line 2, in <module>
    import astropy.units as u
  File "/home/betka/.local/lib/python2.7/site-packages/astropy/__init__.py", line 116, in <module>
    _check_numpy()
  File "/home/betka/.local/lib/python2.7/site-packages/astropy/__init__.py", line 104, in _check_numpy
    from .utils import minversion
ImportError: No module named utils

1 个答案:

答案 0 :(得分:4)

在Javascript中,您可以通过不同的方式来创建该字符串,例如:

const myUrl = "http://www.api.com/" + id + "/foo"

或更好的一个:

const myUrl = `http://www.api.com/${id}/foo`

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

欢呼