描述
工具,根对象。(注意:该控件类型转换相的方法已移至cast控件,最新的WeStudio才支持,请在技术社区下载最新版本)
事件:
screenshot: 截图完成,函数定义:onScreenshot(path, result), path为保存路径, result为布尔值,true-成功,false-失败。
属性:无
方法
名称 | 功能说明 | 脚本例子 |
getOsVersion() | 读取当前ExpOS版本信息 | var ver = util.getOsVersion() 读取当前系统版本信息 |
getModelName() | 读取设置模块名,模拟器里返回"Simulator" | var model = util.getModelName() 读取模块名 |
getDeviceId() | 读取设备标识(20个字符),模拟器返回以EXPOS开头的20个字符 | var id = util.getDeviceId() 读取设备标识 |
getCpuInfo() | 读取CPU信息,返回值为CPU频率以及核心数量(如 “792MHz 1Core”) | var cpu = util.getCpuInfo() 读取cpu信息 |
getMemoryInfo() | 读取内存大小信息(如“492MB”) | var mem = util.getMemoryInfo() 读取内存大小 |
screenshot(path) | 截图当前页面并保存到文件路径,截图完成后会触发onScreenshot(path,result) | util.screenshot('/storage/d0/1.png');截图页面保存到U盘 |
screenshot(path,x,y,width,height) | 截图当前页面指定区域保存到文件路径,适用于保存页面内控件区域 | util.screenshot('/storage/d0/1.png',ui.main.plot.x, ui.main.plot.y,ui.main.plot.width,ui.main.plot.height);截取波形图保存到文件路径 |