本文整理汇总了TypeScript中url.URLSearchParams.delete方法的典型用法代码示例。如果您正苦于以下问题:TypeScript URLSearchParams.delete方法的具体用法?TypeScript URLSearchParams.delete怎么用?TypeScript URLSearchParams.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类url.URLSearchParams
的用法示例。
在下文中一共展示了URLSearchParams.delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: urlWithParams
urlWithParams(newParams: { [key: string]: any }): string {
const params = new URLSearchParams(this._query);
for (const k of Object.keys(newParams)) {
const v = newParams[k];
if (v) {
params.set(k, v);
} else {
params.delete(k);
}
}
const queryString = params.toString();
return format({
protocol: this._protocol,
hostname: this._hostname,
pathname: this._pathname,
slashes: true,
search: queryString == "" ? null : `?${queryString}`,
});
}
示例2: assert
assert.deepEqual(entries.next(), { value: undefined, done: true });
const keys = searchParams.keys();
assert.deepEqual(keys.next(), { value: "abc", done: false });
assert.deepEqual(keys.next(), { value: "abc", done: false });
assert.deepEqual(keys.next(), { value: undefined, done: true });
const values = searchParams.values();
assert.deepEqual(values.next(), { value: "123", done: false });
assert.deepEqual(values.next(), { value: "xyz", done: false });
assert.deepEqual(values.next(), { value: undefined, done: true });
searchParams.set('abc', 'b');
assert.deepEqual(searchParams.getAll('abc'), ['b']);
searchParams.delete('a');
assert(!searchParams.has('a'));
assert.equal(searchParams.get('a'), null);
searchParams.sort();
}
{
const searchParams = new url.URLSearchParams({
user: 'abc',
query: ['first', 'second']
});
assert.equal(searchParams.toString(), 'user=abc&query=first%2Csecond');
assert.deepEqual(searchParams.getAll('query'), ['first,second']);
}