Skip to content

Commit

Permalink
fix(runtime): 补全 window 对象的关键属性
Browse files Browse the repository at this point in the history
京东、支付宝小程序没有 global,会导致 React 必须的 Date、setTimeout 对象没有赋值在 global 上。
当 window 没有这些对象时,直接赋值。
  • Loading branch information
Chen-jj authored and ZakaryCode committed Dec 22, 2020
1 parent b8f8538 commit bb5a728
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/taro-runtime/src/bom/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ if (process.env.TARO_ENV !== 'h5') {
(window as any).requestAnimationFrame = raf;
(window as any).cancelAnimationFrame = caf;
(window as any).getComputedStyle = getComputedStyle
if (!('Date' in window)) {
(window as any).Date = Date
}
if (!('setTimeout' in window)) {
(window as any).setTimeout = setTimeout
}
}

0 comments on commit bb5a728

Please sign in to comment.