English
The js API of uni-app
consists of standard ECMAScript js API and uni extension API.
Standard ECMAScript js is only the most basic js. The browser extends window, document, navigator and other objects based on it. The applet also extends various APIs of wx.xx, my.xx, and swan.xx based on standard js. Node also extends modules such as fs.
uni-app extends uni objects based on ECMAScript, and the API naming remains compatible with applets.
The js code of uni-app
, the h5 side runs in the browser. For non-h5 terminals (including applets and apps), the Android platform runs in the v8 engine, and the iOS platform runs in the jscore engine that comes with iOS, and neither runs in the browser or webview.
On the non-H5 side, although it does not support the js API of browsers such as window, document, and navigator, it also supports standard ECMAScript.
Be careful not to equate js extension objects in browsers with standard js.
Therefore, the non-H5 side of uni-app also supports standard js, syntax such as if and for, variable types such as strings, numbers, time, Boolean values, arrays, custom objects, and various processing methods. It's just that browser-specific objects such as window, document, and navigator are not supported.
uni-app supports not only most ES6 API, but also await/async of ES7.
For the support of ES6 API, see the following table for details (x
means no support, and no special instructions means support):
Because the third-party js engine is not allowed on iOS, there is no distinction between App, applet, and H5 on iOS, and each terminal only depends on the iOS version.
Differences can be seen among Android versions of various sides:
String | iOS8 | iOS9 | iOS10 | Android |
---|---|---|---|---|
codePointAt | ||||
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<5 |
---|---|---|---|---|
Symbol | ||||
Set | ||||
Map | ||||
Proxy | x | x | x | |
Reflect | ||||
Promise |
注意
在App端JS脚本运行在独立的JS引擎中,vue页面使用系统webview渲染,nvue页面使用系统原生View渲染。
正则反向预查 ?<= ?<!,iOS16.4+支持