未验证 提交 1e73b2ef 编写于 作者: O openharmony_ci 提交者: Gitee

!5131 示例代码修改

Merge pull request !5131 from zengyawen/master
# 日志打印
hilog日志系统,使应用/服务可以按照指定级别、标识和格式字符串输出日志内容,帮助开发者了解应用/服务的运行状态,更好地调试程序。
以下文档仅对接口功能进行描述,具体的日志打印要求请参考[OpenHarmony日志打印规范](../../../contribute/OpenHarmony-Log-guide.md)
> **说明:**
> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
......@@ -153,7 +153,7 @@ getIndexOfKey(key: number): number
let plainArray = new PlainArray();
plainArray.add(1, "sddfhf");
plainArray.add(2, "sffdfhf");
let result = plainArray.getIndexOfKey("sdfs");
let result = plainArray.getIndexOfKey(2);
```
......
......@@ -408,7 +408,7 @@ isNrSupported\(slotId: number\): boolean
```js
let slotId = 0;
let result = radio.isNrSupported(slotId);
console.log(result);
console.log("Result: "+ result);
```
......
......@@ -521,7 +521,7 @@ getMaxSimCount\(\): number
**示例:**
```js
console.log(sim.getMaxSimCount())
console.log("Result: "+ sim.getMaxSimCount())
```
......
......@@ -6,7 +6,7 @@
## 导入模块
```
```js
import uri from '@ohos.uri'
```
......@@ -14,7 +14,7 @@ import uri from '@ohos.uri'
### 属性
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Utils.Lang
**系统能力:** SystemCapability.Utils.Lang
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
......@@ -41,7 +41,7 @@ constructor是URI的构造函数。
| 参数名 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| url | string | 是 | 是 | 入参对象。 |
| uri | string | 是 | 是 | 入参对象。 |
**示例:**
......@@ -71,7 +71,7 @@ toString(): string
**示例:**
```js
const url = new uri.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
const url = new uri.URI('http://username:password@host:8080/directory/file?query=pppppp#qwer=da');
url.toString()
```
......
......@@ -23,7 +23,7 @@ import webSocket from '@ohos.net.webSocket';
var defaultIpAddress = "ws://";
let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
console.log("on open, status:" + value['status'] + ", message:" + value['message']);
// 当收到on('open')事件时,可以通过send()方法与服务器进行通信
ws.send("Hello, server!", (err, value) => {
if (!err) {
......@@ -47,7 +47,7 @@ ws.on('message', (err, value) => {
}
});
ws.on('close', (err, value) => {
console.log("on close, code is " + value.code + ", reason is " + value.reason);
console.log("on close, code is " + value['code'] + ", reason is " + value['reason']);
});
ws.on('error', (err) => {
console.log("on error, error:" + JSON.stringify(err));
......@@ -393,7 +393,7 @@ on\(type: 'open', callback: AsyncCallback<Object\>\): void
```js
let ws = webSocket.createWebSocket();
ws.on('open', (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
console.log("on open, status:" + value['status'] + ", message:" + value['message']);
});
```
......@@ -421,7 +421,7 @@ off\(type: 'open', callback?: AsyncCallback<Object\>\): void
```js
let ws = webSocket.createWebSocket();
let callback1 = (err, value) => {
console.log("on open, status:" + value.status + ", message:" + value.message);
console.log("on open, status:" + value['status'] + ", message:" + value['message']);
}
ws.on('open', callback1);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅
......@@ -505,7 +505,7 @@ on\(type: 'close', callback: AsyncCallback<\{ code: number, reason: string \}\>\
```js
let ws = webSocket.createWebSocket();
ws.on('close', (err, value) => {
console.log("on close, code is " + value.code + ", reason is " + value.reason);
console.log("on close, code is " + value['code'] + ", reason is " + value['reason']);
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册