如何在 URL 中合并常量 所以它不会破坏 url
How to merge Constants inside a URL So it won't break the url
我有一个 URL 作为
"http://localhost:8000/api/branding/news/";
我想将域部分放入常量中,例如
export const DOMAIN = "http://localhost:8000/";
现在我在 URL
中添加这个常量
{ DOMAIN } + "api/branding/news/";
但是,这不起作用...如何解决这个问题?
您这样使用 DOMAIN:
DOMAIN + "api/branding/news/"
但更好的是你可以使用模板字符串:
`${DOMAIN}api/branding/news/`
我有一个 URL 作为
"http://localhost:8000/api/branding/news/";
我想将域部分放入常量中,例如
export const DOMAIN = "http://localhost:8000/";
现在我在 URL
中添加这个常量{ DOMAIN } + "api/branding/news/";
但是,这不起作用...如何解决这个问题?
您这样使用 DOMAIN:
DOMAIN + "api/branding/news/"
但更好的是你可以使用模板字符串:
`${DOMAIN}api/branding/news/`