During today's development, the production operation and maintenance personnel reported that the page was blank and unable to enter the system. Upon investigation, it was found that the error was reported by my print-template-designer, reporting that globalThis is not defined.
Actually, it seems like I have encountered this type of error before, usually due to the browser version being too low.
Checking on Can I Use, it was found that globalThis is not supported in versions of Chrome before 70.
So, there are two solutions:
- Have the customer upgrade the browser version
- Upgrade the front end to be compatible with lower versions
In the end, it's best to have the customer upgrade the browser version first. For Windows 7 systems, using the latest version 108 should suffice. (By the way, Chrome stopped supporting Windows 7 this year, and 108 should be the last version)
How to solve it at the code level? Just add the following code to the head.
<head>
<script>
this.globalThis || (this.globalThis = this)
</script>
</head>
Also, understand what globalThis is: