uni-app 在支持绝大部分 ES6 API 的同时,也支持了 ES7 的 await/async。
ES6 API 的支持,详见如下表格部分(x 表示不支持,无特殊说明则表示支持):
- 因为iOS上不允许三方js引擎,所以iOS上不区分App、小程序、H5,各端均仅依赖iOS版本。
- 各端Android版本有差异:
- App端的数据见下表;
- H5端数据见caniuse;
- 微信小程序详见
- 阿里小程序详见
- 百度小程序详见
- 字节跳动小程序详见
- QQ小程序详见
| String | iOS8 | iOS9 | iOS10 | Android |
| :—- | :—- | :—- | :—- | :—- |
| codePointAt | | | | |
| normalize | x | x | | 仅支持 NFD/NFC |
| includes | | | | |
| startsWith | | | | |
| endsWith | | | | |
| repeat | | | | |
| String.fromCodePoint | | | | |
| Array |
iOS8 |
iOS9 |
iOS10 |
Android |
| copyWithin |
|
|
|
|
| find |
|
|
|
|
| findIndex |
|
|
|
|
| fill |
|
|
|
|
| entries |
|
|
|
|
| keys |
|
|
|
|
| values |
x |
|
|
x |
| includes |
x |
|
|
|
| Array.from |
|
|
|
|
| Array.of |
|
|
|
| Number |
iOS8 |
iOS9 |
iOS10 |
Android |
| isFinite |
|
|
|
|
| isNaN |
|
|
|
|
| parseInt |
|
|
|
|
| parseFloat |
|
|
|
|
| isInteger |
|
|
|
|
| EPSILON |
|
|
|
|
| isSafeInteger |
|
|
|
| Math |
iOS8 |
iOS9 |
iOS10 |
Android |
| trunc |
|
|
|
|
| sign |
|
|
|
|
| cbrt |
|
|
|
|
| clz32 |
|
|
|
|
| imul |
|
|
|
|
| fround |
|
|
|
|
| hypot |
|
|
|
|
| expm1 |
|
|
|
|
| log1p |
|
|
|
|
| log10 |
|
|
|
|
| log2 |
|
|
|
|
| sinh |
|
|
|
|
| cosh |
|
|
|
|
| tanh |
|
|
|
|
| asinh |
|
|
|
|
| acosh |
|
|
|
|
| atanh |
|
|
|
| Object |
iOS8 |
iOS9 |
iOS10 |
Android |
| is |
|
|
|
|
| assign |
|
|
|
|
| getOwnPropertyDescriptor |
|
|
|
|
| keys |
|
|
|
|
| getOwnPropertyNames |
|
|
|
|
| getOwnPropertySymbols |
|
|
|
| Other |
iOS8 |
iOS9 |
iOS10 |
Android |
| Symbol |
|
|
|
|
| Set |
|
|
|
|
| Map |
|
|
|
|
| Proxy |
x |
x |
|
x |
| Reflect |
|
|
|
|
| Promise |
|
|
|
注意
- App端Android支持不依赖Android版本号,即便是Android4.4也是上表数据。因为uni-app的js代码运行在自带的独立jscore中,没有js的浏览器兼容性问题。uni-app的vue页面在Android低端机上只有css浏览器兼容性问题,因为vue页面仍然渲染在webview中,受Android版本影响,太新的css语法在低版本不支持。
- 默认不需要在微信工具里继续开启es6转换。但如果用了微信的wxml自定义组件(wxcomponents目录下),uni-app编译器并不会处理这些文件中的es6代码,需要去微信工具里开启转换。从HBuilderX调起微信工具时,如果发现工程下有wxcomponents目录会自动配置微信工程打开es6转换。