本文整理汇总了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);
}
示例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}"`);
}
}
示例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;
}
示例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 };
};
示例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;
};