【发布时间】:2021-08-27 23:22:57
【问题描述】:
我正在尝试传入一个 url 并在 react 中获取这样的主机名:
const url = "https://www.stackoverflow.com/questions/ask";
hostname = baseurl(url);
console.log(hostname);
输出:
stackoverflow
我将如何创建这个函数?
【问题讨论】:
-
查看
new URL(..)
标签: javascript reactjs function url