我有多个参数,当我执行一个get请求时,我只想拥有一个将参数名称作为其值的函数。
问题是,参数是我定义的,而不是值。
this.debounce("search_fullname", 5);
debounce(searchField, value) {
this.$router.push({
query: {
...this.$route.query,
searchField: value
}
})
}
在网址中,我得到/?searchField=5
而不是/?search_fullname=5
答案 0 :(得分:1)
this.debounce("search_fullname", 5);
debounce(searchField, value) {
this.$router.push({
query: {
...this.$route.query,
[searchField]: value <--- Dynamic key in js object
}
})
}
您将在网址中获得/?search_fullname=5
而不是/?searchField=5
。