【发布时间】:2021-05-12 17:56:13
【问题描述】:
我正在尝试从“?external_key=blabla”的 TextFilter 中将文本值附加到以下“http://3-10.cetecerpdevel.com:3101/customer/list_new”。所以换句话说,http://3-10.cetecerpdevel.com:3101/customer/list_new?external_key=blabla。我看过做 react-router 但它似乎不适合我正在做的事情,我尝试了 URLSearchParams。下面的代码是我正在使用的 sn-ps。你会怎么做呢?
function OnChange(text){
if (text === null) {
console.log("Do nothing");
} else {
//append to url
console.log("Hi")
let url = new URL('https://example.com?foo=1&bar=2');
let test = document.getElementById('ExternalKey');
// just append a word to the url
const blah = "blah";
console.log("test",test);
}
}
...
<TextFilter
label="External Key"
urlText={OnChange()}
id="ExternalKey"
placeholder="Search External Key"
dataFieldName="me.external_key"
divClass="form-field column third"
/
【问题讨论】:
标签: javascript reactjs url react-router react-router-dom