本文整理汇总了TypeScript中angular2/src/http/url_search_params.URLSearchParams类的典型用法代码示例。如果您正苦于以下问题:TypeScript URLSearchParams类的具体用法?TypeScript URLSearchParams怎么用?TypeScript URLSearchParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了URLSearchParams类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should support multimap-like merging operation via replaceAll()', () => {
var mapA = new URLSearchParams('a=1&a=2&a=3&c=8');
var mapB = new URLSearchParams('a=4&a=5&a=6&b=7');
mapA.replaceAll(mapB);
expect(mapA.has('a')).toBe(true);
expect(mapA.has('b')).toBe(true);
expect(mapA.has('c')).toBe(true);
expect(mapA.getAll('a')).toEqual(['4', '5', '6']);
expect(mapA.getAll('b')).toEqual(['7']);
expect(mapA.getAll('c')).toEqual(['8']);
expect(mapA.toString()).toEqual('a=4&a=5&a=6&c=8&b=7');
});
开发者ID:1186792881,项目名称:angular,代码行数:12,代码来源:url_search_params_spec.ts
示例2: it
it('should conform to spec', () => {
var paramsString = "q=URLUtils.searchParams&topic=api";
var searchParams = new URLSearchParams(paramsString);
// Tests borrowed from example at
// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
// Compliant with spec described at https://url.spec.whatwg.org/#urlsearchparams
expect(searchParams.has("topic")).toBe(true);
expect(searchParams.has("foo")).toBe(false);
expect(searchParams.get("topic")).toBe("api");
expect(searchParams.getAll("topic")).toEqual(["api"]);
expect(searchParams.get("foo")).toBe(null);
searchParams.append("topic", "webdev");
expect(searchParams.getAll("topic")).toEqual(["api", "webdev"]);
expect(searchParams.toString()).toBe("q=URLUtils.searchParams&topic=api&topic=webdev");
searchParams.delete("topic");
expect(searchParams.toString()).toBe("q=URLUtils.searchParams");
});
开发者ID:AsherBarak,项目名称:angular,代码行数:18,代码来源:url_search_params_spec.ts
示例3: it
it('should conform to spec', () => {
var paramsString = 'q=URLUtils.searchParams&topic=api';
var searchParams = new URLSearchParams(paramsString);
// Tests borrowed from example at
// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
// Compliant with spec described at https://url.spec.whatwg.org/#urlsearchparams
expect(searchParams.has('topic')).toBe(true);
expect(searchParams.has('foo')).toBe(false);
expect(searchParams.get('topic')).toEqual('api');
expect(searchParams.getAll('topic')).toEqual(['api']);
expect(searchParams.get('foo')).toBe(null);
searchParams.append('topic', 'webdev');
expect(searchParams.getAll('topic')).toEqual(['api', 'webdev']);
expect(searchParams.toString()).toEqual('q=URLUtils.searchParams&topic=api&topic=webdev');
searchParams.delete('topic');
expect(searchParams.toString()).toEqual('q=URLUtils.searchParams');
// Test default constructor
expect(new URLSearchParams().toString()).toBe('');
});
开发者ID:LordBinary,项目名称:angular,代码行数:21,代码来源:url_search_params_spec.ts
注:本文中的angular2/src/http/url_search_params.URLSearchParams类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论