本文整理汇总了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 */