LI.FI Widget 使用现代 JavaScript API,这些 API 在较旧的环境中可能不受支持。集成 Widget 的合作伙伴如果需要支持较旧的浏览器,可能需要添加 polyfill。
只有当你必须支持下表中某个 API 标记为 ❌ 的环境时,才需要 polyfill。本页中的 polyfill 包/导入仅为建议——只要能提供相同的 API 行为,你可以使用任何等效的 polyfill 解决方案。
浏览器与 API 支持
API
Polyfill
iOS 15.0-15.3
iOS 15.4+
iOS 16.0+
Chrome 92+
Firefox 92+
Safari 15.4+
Safari 16.0+
Samsung 16.0+
structuredClone()
core-js/actual/structured-clone
❌
✅
✅
✅
✅
✅
✅
✅
Array.at()
core-js/actual/array/at
❌
✅
✅
✅
✅
✅
✅
✅
Object.hasOwn()
core-js/actual/object/has-own
❌
✅
✅
✅
✅
✅
✅
✅
Array.findLast()
core-js/actual/array/find-last
❌
✅
✅
✅
✅
✅
✅
✅
Array.findLastIndex()
core-js/actual/array/find-last-index
❌
✅
✅
✅
✅
✅
✅
✅
Array.toSpliced()
core-js/actual/array/to-spliced
❌
❌
✅
✅
✅
❌
✅
✅
Array.toSorted()
core-js/actual/array/to-sorted
❌
❌
✅
✅
✅
❌
✅
✅
Array.with()
core-js/actual/array/with
❌
❌
✅
✅
✅
❌
✅
✅
图例: ❌ 不支持(需要 polyfill) | ✅ 完全支持
Polyfill 设置(示例)
安装 polyfill 库
npm install core-js
导入 polyfill(选择一种方式)
方案 A:最简单(打包体积较大)
// Place at the very beginning of your app entry point (before importing the Widget)import 'core-js'
方案 B:只导入你需要的(打包体积较小)
// Place at the very beginning of your app entry point (before importing the Widget)import 'core-js/actual/structured-clone'import 'core-js/actual/array/at'import 'core-js/actual/object/has-own'import 'core-js/actual/array/find-last'import 'core-js/actual/array/find-last-index'import 'core-js/actual/array/to-spliced'import 'core-js/actual/array/to-sorted'import 'core-js/actual/array/with'