當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript UrlSearchParams.getAll函數代碼示例

本文整理匯總了TypeScript中src/UrlSearchParams.getAll函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getAll函數的具體用法?TypeScript getAll怎麽用?TypeScript getAll使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getAll函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: checkParams

	construct: (function () {
		function checkParams(params: UrlSearchParams) {
			assert.deepEqual(params.getAll('foo'), [ 'bar', 'baz' ]);
			assert.deepEqual(params.getAll('bar'), [ 'foo' ]);
			assert.deepEqual(params.getAll('baz'), [ '' ]);
		}

		return {
			empty() {
				// Empty UrlSearchParams should have no properties
				const params = new UrlSearchParams();
				assert.isNull(params.get('foo'));
			},

			// Next three tests should generate 'params' objects with same contents

			object() {
				const params = new UrlSearchParams({ foo: [ 'bar', 'baz' ], bar: 'foo', baz: null });
				checkParams(params);
			},

			string() {
				let params = new UrlSearchParams('foo=bar&foo=baz&bar=foo&baz');
				checkParams(params);

				// Assignments after the first will be ignored
				params = new UrlSearchParams('foo=bar=baz');
				assert.deepEqual(params.getAll('foo'), [ 'bar' ]);

				// Handle empty keys
				params = new UrlSearchParams('=foo&');
				assert.deepEqual(params.getAll(''), [ 'foo', '' ]);
			},

			UrlSearchParams() {
				const params1 = new UrlSearchParams({ foo: [ 'bar', 'baz' ], bar: 'foo', baz: null });
				const params = new UrlSearchParams(params1);
				checkParams(params);
			}
		}
	})(),
開發者ID:jdonaghue,項目名稱:core,代碼行數:41,代碼來源:UrlSearchParams.ts

示例2: UrlSearchParams

			},

			UrlSearchParams() {
				const params1 = new UrlSearchParams({ foo: [ 'bar', 'baz' ], bar: 'foo', baz: null });
				const params = new UrlSearchParams(params1);
				checkParams(params);
			}
		}
	})(),

	'#append': {
		'new key'() {
			// Appending with a new key is the same as 'set'
			const params = new UrlSearchParams();
			params.append('foo', 'bar');
			assert.deepEqual(params.getAll('foo'), [ 'bar' ]);
		},

		'existing key'() {
			const params = new UrlSearchParams({ foo: 'bar' });
			params.append('foo', 'baz');
			assert.deepEqual(params.getAll('foo'), [ 'bar', 'baz' ]);
		}
	},

	'#delete'() {
		const params = new UrlSearchParams({ foo: 'bar' });
		params.delete('foo');
		assert.isNull(params.get('foo'));
	},
開發者ID:jdonaghue,項目名稱:core,代碼行數:30,代碼來源:UrlSearchParams.ts


注:本文中的src/UrlSearchParams.getAll函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。