恩 浏览器兼容 换赛道了呢
好久没升级的我遇到了 Object.hasOwn is not a function
错误
1 | Mozilla/5.0 (Linux; Android 12; 2112123AG Build/SKQ1.220303.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/4263 MMWEBSDK/20220604 Mobile Safari/537.36 MMWEBID/2083 MicroMessenger/8.0.24.2167(0x28001843) WeChat/arm64 Weixin GPVersion/1 NetType/WIFI Language/zh_CN ABI/arm64 |
看了看应用的包 发现 ky
这个现代的有趣家伙
恩 搜了搜 发现优雅的解决方案
main.ts
1 | import * as hasOwn from 'object.hasown' |
参考地址
- https://github.com/sindresorhus/ky/issues/629
- https://github.com/vitejs/vite/discussions/15794
- https://ccny.ltd/views/blog/2022/%E4%BB%8E%20Object.hasOwn%20%E7%9C%8B%20@vitejs_plugin-legacy.html