當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript global.document類代碼示例

本文整理匯總了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;未經允許,請勿轉載。