如何将提取的用户ID放入Mern堆栈的文本字段中

时间:2020-09-23 13:52:53

标签: reactjs mern

  • 我正在使用MERN Stack建立网站。我在网址http://localhost:3000/5f539fbf8e7b1c16806a863f%20/new_appointment上有此数据,其中5f539fbf8e7b1c16806a863f是唯一的ID。我想在标签或文本字段中返回该ID。

已解决 已使用this.props.match.params.id

1 个答案:

答案 0 :(得分:0)

有很多方法可以做到这一点,但我更喜欢这种方式。

const url ="http://localhost:3000/5f539fbf8e7b1c16806a863f%20/new_appointment"

const idMix = url.split("/")[3]

const id = idMix.split("%")[0]

我希望它能解决您的问题。