低版本浏览器数组不支持at函数问题修复

This commit is contained in:
Allen
2024-04-05 04:11:50 +00:00
parent 3a4e936938
commit 6f68732ef9
2 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
/**
* 浏览器兼容性处理
*/
/**
* 修复低版本Safari等浏览器数组不支持at函数的问题
*/
export function fixArrayAt() {
if (!Array.prototype.at) {
Array.prototype.at = function(index: number) {
if (index >= 0) {
return this[index]
} else {
return this[this.length + index]
}
}
}
}

View File

@@ -4,6 +4,7 @@ import { useToast } from 'vue-toast-notification'
import api from '@/api'
import type { TransferHistory } from '@/api/types'
import ReorganizeForm from '@/components/form/ReorganizeForm.vue'
import { fixArrayAt } from '@/@core/utils/compatibility'
// 提示框
const $toast = useToast()
@@ -304,6 +305,9 @@ const dropdownItems = ref([
},
},
])
// 修复低版本Safari等浏览器数组不支持at函数的问题
fixArrayAt()
</script>
<template>