解决 pdf.js 出现 TypeError: key.split(...).at is not a function 报错问题

问题

使用pdf.js v2版本部分机型出现 TypeError: key.split(...).at is not a function 报错

解决

参考 https://github.com/wojtekmaj/react-pdf/issues/1465

方式一(推荐)
javascript 复制代码
 import 'core-js/features/array/at';
方式二 (解决了部分机型浏览器问题)
javascript 复制代码
  if (!Array.prototype.at) {
    Array.prototype.at = function (index) {
      if (index < 0) {
        index = this.length + index;
      }
      if (index >= 0 && index < this.length) {
        return this[index];
      }
      return undefined;
    };
  }
相关推荐
红尘散仙8 小时前
谁说终端只能敲键盘?我用 Rust 给小说阅读器加上了鼠标
前端·后端·rust
Penge6668 小时前
《Go 后端开发者学 React:组件通信与插槽》
javascript
陈随易9 小时前
C++26 草案被否,二十八年来头一回
前端·后端·程序员
ZhengEnCi9 小时前
Agent 工具怎么折叠海量输出才「爽」:Trae、Claude Code 的渐进式披露设计原理
前端·agent
Penge6669 小时前
《Go 后端开发者学 React:useState》
javascript
Penge6669 小时前
《Go 后端开发者学 React:数据渲染》
javascript
IT_陈寒12 小时前
Redis内存暴涨,没想到是AOF重写捣的鬼
前端·人工智能·后端
ikoala12 小时前
让 Codex 自己查账:一个省 token 的小技巧
前端·后端·ai编程
ikoala12 小时前
AI 写页面像说明书,修 Bug 像贴膏药?把这两句话写进 AGENTS.md
前端·javascript·ai编程
Penge66613 小时前
《Go 后端开发者学 TypeScript:ES Module了解》
javascript