容器版本判断
框架提供了版本判断函数,可以针对某些不支持的功能进行特殊处理。
import { system, compareVersion } from 'waft';
/**
{
"screenWidth":1280,
"screenHeight":800,
"pixelRatio":1.25,
"platform":"Android",
"system":"6.1.8-D-20201202.2128",
"version":"1.1.191",
"versionCode":191,
"app":"com.alibaba.genie.waft",
"sdkVersion":"0.3",
"sdkVersionCode":3,
"model":"AILABS_S3",
"brand":"alps"
}
*/
const version = system.getSystemInfoCache().version;
// 某功能只在 >= 1.5 versionCode后生效
const result = compareVersion(version, "1.5");
// 大于等于该版本,生效
if(result >= 0){
}
最低运行的容器版本限定
如果应用核心功能都无法在某版本以下运行,建议设置最低版本的字段。
在app.json中,配置minVersion字段可以限制最低版本容器:
{
"pages": [
"pages/index/index",
"pages/waft-index/waft-index"
],
"default": "pages/index/index",
"viewport":{
"width": 1024,
"height": 600,
"scaleMode": "fixedHeight"
},
"minVersion": "1.3"
}
在不支持的版本中,将会对用户出现升级页面。(后续会加入点击升级的按钮)