解决 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;
    };
  }
相关推荐
qcx236 分钟前
【系统学AI】25 论文导读 ①:两篇改变 AI 的开山之作——Attention Is All You Need & ReAct
前端·人工智能·react.js·transformer
kyriewen1 小时前
大文件上传最全指南:分片、断点续传、秒传,一篇就够了
前端·javascript·面试
我叫黑大帅2 小时前
解决聊天页内部滚轮改为页面滚动问题
javascript·后端·面试
郑洁文2 小时前
基于Python的Web命令执行漏洞自动化检测系统
前端·python·网络安全·自动化
新酱爱学习2 小时前
手搓 10 个 Skill 后,我把重复劳动收敛成了一套零依赖 CLI 工具
前端·javascript·人工智能
罗超驿2 小时前
13.JavaScript 新手入门指南:语法、变量、流程控制全解析
开发语言·javascript
IT_陈寒2 小时前
Python的线程池居然把我坑在了垃圾回收这块
前端·人工智能·后端
ct9783 小时前
Three.js 性能优化(测量-定位-优化)
javascript·性能优化·three
研☆香3 小时前
es6新特性功能介绍(一)
前端·ecmascript·es6