URLSearchParams: phương thức getAll()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.
Note: This feature is available in Web Workers.
Phương thức getAll() của giao diện URLSearchParams trả về tất cả các giá trị gắn với một tham số truy vấn đã cho dưới dạng một mảng.
Cú pháp
js
getAll(name)
Tham số
name-
Tên của tham số cần trả về.
Giá trị trả về
Một mảng các chuỗi, có thể rỗng nếu không tìm thấy giá trị nào cho tham số đã cho.
Ví dụ
js
const url = new URL("https://example.com?foo=1&bar=2");
const params = new URLSearchParams(url.search);
// Thêm một tham số foo thứ hai.
params.append("foo", 4);
console.log(params.getAll("foo")); // ["1", "4"]
Thông số kỹ thuật
| Specification |
|---|
| URL> # dom-urlsearchparams-getall> |