解决 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;
    };
  }
相关推荐
宿67413 分钟前
vue3-包管理器
前端·vue.js
weixin_4692738116 分钟前
如何在线把文字转为 pdf 文档
pdf
@PHARAOH25 分钟前
WHAT - Remix 入门和基本实践:理解两套产物
前端·remix
2601_963906781 小时前
离线截图 OCR 识别:支持表格与 PDF 解析
pdf·ocr·软件需求
mayaairi1 小时前
Vue2 生命周期完全指南:从创建到销毁的8个钩子函数
前端·javascript·vue.js
研☆香2 小时前
一个简单的气泡弹窗制作
javascript
xy34532 小时前
axure9.0 如何打造一个计时器(简单版)
前端·ui·html·axure·原型·产品设计
大模型丫丫2 小时前
用 TypeScript、NestJS 和 LangGraph 搭建一个可控的 AI Agent
javascript·人工智能·typescript
IMPYLH2 小时前
HTML 的 <pre> 元素
前端·javascript·html
shmily麻瓜小菜鸡3 小时前
JavaScript / TypeScript 易踩坑知识点 —— 异步编程类
开发语言·javascript·typescript