1、获取mac地址权限:ohos.permission.GET\_WIFI\_INFO代码:wifiManager.getLinkedInfo().then( data => { console.info("get wifi linked info: " + JSON.stringify(data)); }).catch((error: number) => { console.info("get linked info error"); }); 参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-wifimanager-V5\#wifimanagergetlinkedinfo92、获取ip地址权限:ohos.permission.GET\_NETWORK\_INFO代码:let netHandle = await connection.getDefaultNet(); if (netHandle) { let connectionProperties = await connection.getConnectionProperties(netHandle) if (connectionProperties && connectionProperties.linkAddresses) { connectionProperties.linkAddresses.forEach((address: connection.LinkAddress, index: number) => { console.info("get address info: " + JSON.stringify(address)); }) } } 参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-net-connection-V5\#connectiongetconnectionproperties
1、获取mac地址权限:ohos.permission.GET\_WIFI\_INFO代码:
参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-wifimanager-V5\#wifimanagergetlinkedinfo9
2、获取ip地址权限:ohos.permission.GET\_NETWORK\_INFO代码:
参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-net-connection-V5\#connectiongetconnectionproperties