本文整理汇总了TypeScript中global.document类的典型用法代码示例。如果您正苦于以下问题:TypeScript document类的具体用法?TypeScript document怎么用?TypeScript document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了document类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: addCssWarning
export default function addCssWarning() {
const warning = document.createElement('h1');
warning.textContent = 'CSS rules are not configured as needed';
warning.className = 'css-rules-warning';
warning.style.color = 'red';
document.body.insertBefore(warning, document.body.firstChild);
}
开发者ID:chinmaymoharir,项目名称:storybook,代码行数:8,代码来源:cssWarning.ts
示例2: constructor
constructor(private readonly config: Config) {
this.buffer = [];
this.handler = null;
window.addEventListener('message', this.handleEvent.bind(this), false);
document.addEventListener('DOMContentLoaded', () => this.flush());
// Check whether the config.page parameter has a valid value
if (config.page !== 'manager' && config.page !== 'preview') {
throw new Error(`postmsg-channel: "config.page" cannot be "${config.page}"`);
}
}
开发者ID:chinmaymoharir,项目名称:storybook,代码行数:10,代码来源:index.ts
示例3: getWindow
private getWindow(): Window {
if (this.config.page === 'manager') {
// FIXME this is a really bad idea! use a better way to do this.
// This finds the storybook preview iframe to send messages to.
const iframe = document.getElementById('storybook-preview-iframe');
if (!iframe) {
return null;
}
return iframe.contentWindow;
}
return window.parent;
}
开发者ID:chinmaymoharir,项目名称:storybook,代码行数:12,代码来源:index.ts
示例4: createElement
const getElement = (id: string, code: string) => {
const found: Element = document.querySelector(`[id="storybook-addon-resource_${id}"]`);
return { element: found || createElement(id, code), created: !found };
};
开发者ID:chinmaymoharir,项目名称:storybook,代码行数:4,代码来源:index.ts
示例5:
const createElement = (id: string, code: string): HTMLDivElement => {
const element: HTMLDivElement = document.createElement('div');
element.setAttribute('id', `storybook-addon-resource_${id}`);
element.innerHTML = code;
return element;
};
开发者ID:chinmaymoharir,项目名称:storybook,代码行数:6,代码来源:index.ts
注:本文中的global.document类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论