本文整理匯總了TypeScript中dojo/query.query函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript query函數的具體用法?TypeScript query怎麽用?TypeScript query使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了query函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: override
clearSelection: override(function (inherited) {
inherited(arguments);
query("input[type=checkbox]", this.domNode).forEach(function (node) {
node.checked = false;
node.indeterminate = false;
});
}),
示例2: query
def.callback(function (xmlDoc) {
var results = query('bar', xmlDoc);
assert.strictEqual(results.length, 2);
}),
示例3: query
import * as query from 'dojo/query';
/* An example of working with query and NodeLists */
/* Querying all the nodes of the current document. The will default to the node
list being an array of Nodes */
const results = query('*');
/* Now we are going to assert that we will be only returning HTML elements,
this now means resulting functions will be typed appropriately */
results
.filter<HTMLElement>((node) => node.parentElement === document.body)
.forEach((item) => {
/* item is typed as HTMLElement */
console.log(item.tagName);
});
/* If we want to assert what types of nodes our query will return, we can do that
upfront */
const myDiv = document.createElement('div');
const myP = document.createElement('p');
query<HTMLDivElement>('div')
.concat(myDiv)
.forEach((div) => {
console.log(div.noWrap);
});
/* it will also type guard us, for example, if you uncomment the below, you will
throw a type error */