[英]ReferenceError: Can't find variable: globalThis
I have a angular 9 based website which is hosted in firebase.我有一个基于 angular 9 的网站,该网站托管在 firebase 中。 I have an issue which happens only on some devices like iphone 6/7/8.我有一个问题,仅在某些设备上发生,例如 iphone 6/7/8。 Not all of them but really often.不是全部,但确实经常。
Error text : main-es5.d57a465….js:1 ReferenceError: Can't find variable: globalThis(anonymous function) @ main-es5.d57a465….js:1spgP @ main-es5.d57a465….js:1a @ runtime-es5.7388edc….js:1zUnb @ main-es5.d57a465….js:1a @ runtime-es5.7388edc….js:1(anonymous function) @ main-es5.d57a465….js:1a @ runtime-es5.7388edc….js:1t @ runtime-es5.7388edc….js:1r @ runtime-es5.7388edc….js:1global code @ main-es5.d57a465….js:1错误文本:main-es5.d57a465….js:1 ReferenceError: 找不到变量:globalThis(匿名函数)@ main-es5.d57a465….js:1spgP @ main-es5.d57a465….js:1a @ runtime -es5.7388edc….js:1zUnb @ main-es5.d57a465….js:1a @ runtime-es5.7388edc….js:1(匿名函数) @ main-es5.d57a465….js:1a @ runtime-es5 .7388edc….js:1t @ runtime-es5.7388edc….js:1r @ runtime-es5.7388edc….js:1 全局代码 @ main-es5.d57a465….js:1
Another error: main-es2015.d57a465….js:1 ReferenceError: Can't find variable: globalThis(anonymous function) @ main-es2015.d57a465….js:1spgP @ main-es2015.d57a465….js:1a @ runtime-es2015.7388edc….js:1zUnb @ main-es2015.d57a465….js:1a @ runtime-es2015.7388edc….js:1(anonymous function) @ main-es2015.d57a465….js:1a @ runtime-es2015.7388edc….js:1t @ runtime-es2015.7388edc….js:1module code @ main-es2015.d57a465….js:1evaluate @ [native code]:1moduleEvaluation @ [native code]:1另一个错误: main-es2015.d57a465….js:1 ReferenceError: Can't find variable: globalThis(anonymous function) @ main-es2015.d57a465….js:1spgP @ main-es2015.d57a465….js:1a @ runtime -es2015.7388edc….js:1zUnb @ main-es2015.d57a465….js:1a @ runtime-es2015.7388edc….js:1(匿名函数) @ main-es2015.d57a465….js:1a @ runtime-es2015 .7388edc….js:1t @ runtime-es2015.7388edc….js:1module 代码 @ main-es2015.d57a465….js:1evaluate @ [native code]:1moduleEvaluation @ [native code]:1
iOS Safari support for globalThis
is version 12.2 or later. iOS Safari 支持全球globalThis
是版本 12.2 或更高版本。
For earlier versions, you will need a polyfill .对于早期版本,您将需要一个polyfill 。 check if globalThis
is not defined then include the polyfill.检查globalThis
是否未定义,然后包含 polyfill。
And if your app is always running in a browser just replace globalThis with window如果您的应用程序始终在浏览器中运行,只需将 globalThis 替换为 window
Best way to solve this problem in Angular <11
is to add in index.html在Angular <11
中解决此问题的最佳方法是添加 index.html
<script src="//unpkg.com/@ungap/global-this"></script>
Thanks for this solution https://github.com/ungap/global-this感谢您提供此解决方案https://github.com/ungap/global-this
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.