解决 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;
    };
  }
相关推荐
yqcoder3 小时前
闭包是什么?优缺点、怎么防内存泄漏?
前端·http
riuphan3 小时前
JavaScript 中的 this 关键字
javascript
掰头战士3 小时前
五分钟带你深入了解 this
javascript
lichenyang4533 小时前
鸿蒙 ArkUI 组件基础复盘:从两个 UI 卡片回到 ComponentV2、状态管理和组件分层
前端
biubiubiu_LYQ3 小时前
萌新小白基础理解篇之 this 关键字
前端·javascript
甜味弥漫3 小时前
深度解析 JS 中的 this 指向:从底层逻辑到实战规则
javascript·面试
光影少年3 小时前
Redux 中间件作用(redux-thunk/redux-saga)
前端·react.js·掘金·金石计划
爱上好庆祝3 小时前
学习JS第十一天(JS的进阶)
前端·javascript·学习
喵个咪4 小时前
统一范式:中后台Admin项目标准化API分层开发方案(Vue/React通用)
前端·vue.js·react.js
Shirley~~4 小时前
figma Mcp
前端·ai编程