解决 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;
    };
  }
相关推荐
冴羽9 分钟前
SvelteKit 最新中文文档教程(4)—— 表单 actions
前端·javascript·svelte
搬砖-无恙22 分钟前
vue uniapp里照片多张照片展示
前端·vue.js·uni-app
菜又爱编程24 分钟前
【uni-app运行错误】SassError: expected selector @import “@/uni.scss“;
前端·uni-app·scss
草明30 分钟前
使用 Chrome Flags 设置(适用于 HTTP 站点开发)
前端·chrome·http
互联网搬砖老肖1 小时前
Python开发合并多个PDF文件
java·python·pdf
sunly_1 小时前
Flutter:签名板封装
开发语言·javascript·flutter
GISer_Jing1 小时前
设计模式分类解析与JavaScript实现
开发语言·javascript·设计模式
Tz一号1 小时前
前端 git规范-不同软件(GitHub、Sourcetree、WebStorm)、命令行合并方式下增加 --no-ff的方法
前端·git·github
Loadings1 小时前
MCP从理解到实现
前端·cursor·ai 编程
冬冬小圆帽2 小时前
防止手机验证码被刷:React + TypeScript 与 Node.js + Express 的全面防御策略
前端·后端·react.js·typescript