配置了系统信息权限,应用无法获取设备的系统信息。
配置如下:
// 在 config.json 中添加系统信息权限
{
"module": {
"reqPermissions": [
{
"name": "ohos.permission.GET_SYSTEM_INFO"
}
]
}
}获取系统信息:
// 获取系统信息
import device from '@system.device';
device.getInfo({
success: (data) => {
console.log('System info:', data);
},
fail: (error) => {
console.error('Failed to get system info', error);
}
});
是不是权限问题?config.json里面看看