prototype.ts 441 B

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