当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript URLSearchParams.toString方法代码示例

本文整理汇总了TypeScript中angular2/src/http/url_search_params.URLSearchParams.toString方法的典型用法代码示例。如果您正苦于以下问题:TypeScript URLSearchParams.toString方法的具体用法?TypeScript URLSearchParams.toString怎么用?TypeScript URLSearchParams.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/src/http/url_search_params.URLSearchParams的用法示例。


在下文中一共展示了URLSearchParams.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: 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

示例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.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。