小程序的運(yùn)行環(huán)境
智能小程序運(yùn)行在三端: iOS 、 Android 和 用于調(diào)試的開發(fā)者工具。
三端的腳本執(zhí)行環(huán)境以及用于渲染非原生組件的環(huán)境是各不相同的:
iOS
- 舊版本,小程序的邏輯層、視圖層,均運(yùn)行在 webview 中,并進(jìn)行渲染。
- 新版本,小程序的邏輯層的 js 代碼運(yùn)行在 jscore 中,視圖層在 webview 中渲染。
Android
- 舊版本,小程序的邏輯層、視圖層,均運(yùn)行在 webview 中,并進(jìn)行渲染。
- 新版本,小程序的邏輯層的 js 代碼運(yùn)行在 V8 中,視圖層基于自研的 T7 內(nèi)核在 webview 渲染。
開發(fā)工具
小程序邏輯層的 javascript 代碼是運(yùn)行在 electron 中,視圖層是由 Chromium 59.0.3071.115 Webview 來渲染的。
平臺差異
盡管三端的環(huán)境是十分相似的,但是還是有些許區(qū)別,例如 ES6 、 CSS 的差異,還是建議開發(fā)者需要在 iOS 和 Android 上分別檢查小程序的真實(shí)表現(xiàn)。
開發(fā)者工具僅供調(diào)試使用,最終的表現(xiàn)以客戶端為準(zhǔn)。
ES6 支持情況
智能小程序基礎(chǔ)庫內(nèi)置了 polyfill 的解決方案,已經(jīng)支持了絕大部分的 ES6 API 。具體如下:
- es7.array.includes
- es6.array.find-index
- es6.array.from
- es6.array.find
- es6.array.fill
- es6.array.copy-within
- es6.object.get-own-property-descriptor
- es7.object.entries
- es6.object.assign
- es7.object.values
- es6.math.asinh
- es6.math.atanh
- es6.math.cbrt
- es6.math.expm1
- es6.math.clz32
- es6.math.cosh
- es6.math.fround
- es6.math.hypot
- es6.math.log1p
- es6.math.log2
- es6.math.log10
- es6.math.sign
- es6.math.sinh
- es6.math.tanh
- es6.math.trunc
- es6.string.from-code-point
- es6.string.code-point-at
- es6.string.starts-with
- es6.string.ends-with
- es6.string.includes
- es6.string.repeat
- es7.string.pad-start
- es7.string.pad-end
- es6.regexp.flags
- es6.map
- es6.weak-map
- es6.set
- es6.weak-set
- es6.symbol
- es6.reflect.apply
- es6.reflect.construct
- es6.reflect.define-property
- es6.reflect.delete-property
- es6.reflect.get
- es6.reflect.get-own-property-descriptor
- es6.reflect.get-prototype-of
- es6.reflect.has
- es6.reflect.is-extensible
- es6.reflect.own-keys
- es6.reflect.prevent-extensions
- es6.reflect.set
- es6.reflect.set-prototype-of
- es7.promise.finally
- es6.array.iterato
其他不在列表中說明的新特性,例如 await async 等,目前暫不支持。
更多建議: