prototype.ts 410 B

123456789101112131415
  1. export const prototypeInterceptor = {
  2. install() {
  3. // 解决低版本手机不识别 array.at() 导致运行报错的问题
  4. if (typeof Array.prototype.at !== 'function') {
  5. Array.prototype.at = function (index: number) {
  6. if (index < 0)
  7. return this[this.length + index]
  8. if (index >= this.length)
  9. return undefined
  10. return this[index]
  11. }
  12. }
  13. },
  14. }