add Array.prototype.at polyfill to fix js error in weixin
This commit is contained in:
fantasticit 2023-01-08 13:27:46 +08:00
parent f9bcf31df0
commit 1d2c9402f2
2 changed files with 9 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import 'styles/globals.scss';
import 'tiptap/core/styles/index.scss'; import 'tiptap/core/styles/index.scss';
import '@react-pdf-viewer/core/lib/styles/index.css'; import '@react-pdf-viewer/core/lib/styles/index.css';
import '@react-pdf-viewer/default-layout/lib/styles/index.css'; import '@react-pdf-viewer/default-layout/lib/styles/index.css';
import 'thirtypart/array-prototype-at';
import { Worker } from '@react-pdf-viewer/core'; import { Worker } from '@react-pdf-viewer/core';
import { isMobile } from 'helpers/env'; import { isMobile } from 'helpers/env';

View File

@ -0,0 +1,8 @@
if (![].at) {
Array.prototype.at = function at(n) {
n = Math.trunc(n) || 0;
if (n < 0) n += this.length;
if (n < 0 || n >= this.length) return undefined;
return this[n];
};
}