本文整理匯總了TypeScript中@phosphor/commands.CommandRegistry.label方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CommandRegistry.label方法的具體用法?TypeScript CommandRegistry.label怎麽用?TypeScript CommandRegistry.label使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@phosphor/commands.CommandRegistry
的用法示例。
在下文中一共展示了CommandRegistry.label方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should give the appropriate label given arguments', () => {
let cmd = {
execute: (args: JSONObject) => { return args; },
label: (args: JSONObject) => { return JSON.stringify(args); }
};
registry.addCommand('test', cmd);
expect(registry.label('test', {})).to.equal('{}');
});
示例2: setNodeContentFromCommand
function setNodeContentFromCommand(node: HTMLElement, commands: CommandRegistry, id: string): void {
const iconClass = commands.iconClass(id);
const iconLabel = commands.iconLabel(id);
const label = commands.label(id);
node.innerHTML = '';
if (iconClass) {
node.className += ` ${iconClass}`;
node.setAttribute('title', iconLabel || label);
} else {
node.innerText = label;
}
}
示例3: setNodeContentFromCommand
function setNodeContentFromCommand(node: HTMLElement, commands: CommandRegistry, id: string): void {
let iconClass = commands.iconClass(id);
let iconLabel = commands.iconLabel(id);
node.innerHTML = '';
if (iconClass || iconLabel) {
let icon = document.createElement('div');
icon.innerText = commands.iconLabel(id);
icon.className += ` ${iconClass}`;
node.appendChild(icon);
} else {
node.innerText = commands.label(id);
}
}