解决 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;
    };
  }
相关推荐
电商api接口开发1 分钟前
ASP.NET MVC 入门指南二
前端·c#·html·mvc
亭台烟雨中14 分钟前
【前端记事】关于electron的入门使用
前端·javascript·electron
泯泷28 分钟前
「译」解析 JavaScript 中的循环依赖
前端·javascript·架构
抹茶san31 分钟前
前端实战:从 0 开始搭建 pnpm 单一仓库(1)
前端·架构
Senar1 小时前
Web端选择本地文件的几种方式
前端·javascript·html
烛阴1 小时前
UV Coordinates & Uniforms -- OpenGL UV坐标和Uniform变量
前端·webgl
姑苏洛言1 小时前
扫码小程序实现仓库进销存管理中遇到的问题 setStorageSync 存储大小限制错误解决方案
前端·后端
烛阴1 小时前
JavaScript 的 8 大“阴间陷阱”,你绝对踩过!99% 程序员崩溃瞬间
前端·javascript·面试