From 90e11e98a5118d2dbd6b281e7acda04b04887e35 Mon Sep 17 00:00:00 2001 From: zhangmenghan Date: Mon, 28 Oct 2024 17:33:10 +0800 Subject: [PATCH] modified Signed-off-by: zhangmenghan --- .../src/main/ets/pages/javascript/jsobjectwrap/napiwrap.ets | 5 ++++- .../ohosTest/ets/test/javascriptapi/jsobjectwrap.test.ets | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/napitutorials/entry/src/main/ets/pages/javascript/jsobjectwrap/napiwrap.ets b/examples/napitutorials/entry/src/main/ets/pages/javascript/jsobjectwrap/napiwrap.ets index 1ed3e81c..7a22b075 100644 --- a/examples/napitutorials/entry/src/main/ets/pages/javascript/jsobjectwrap/napiwrap.ets +++ b/examples/napitutorials/entry/src/main/ets/pages/javascript/jsobjectwrap/napiwrap.ets @@ -33,6 +33,8 @@ struct napiwrap { @State testcont: string = ' // 测试 N-API napi_wrap \n' + ' const result = testNapi.testNapiWrap(); \n' + ' console.log(result); \n' + + ' const ret = result.Tyof(1024); \n' + + ' console.log(ret);\n' controller: TextAreaController = new TextAreaController() @@ -84,8 +86,9 @@ struct napiwrap { .id('napi_wrap') .onClick(() => { let node: testNapi.testNapiWrap = new testNapi.testNapiWrap(); - console.log(`Node.Tyof('1024') is ${node.Tyof(1024)}`); + let ret = node.Tyof(1024); this.testcont = this.testcont.replace('log(result)', 'log(## type of node is ' + typeof (node) + ' ##)'); + this.testcont = this.testcont.replace('log(ret)', 'log(## ' + ret + ' ##)'); }) } .width('100%') diff --git a/examples/napitutorials/entry/src/ohosTest/ets/test/javascriptapi/jsobjectwrap.test.ets b/examples/napitutorials/entry/src/ohosTest/ets/test/javascriptapi/jsobjectwrap.test.ets index 5bdb6eff..5eb708a3 100644 --- a/examples/napitutorials/entry/src/ohosTest/ets/test/javascriptapi/jsobjectwrap.test.ets +++ b/examples/napitutorials/entry/src/ohosTest/ets/test/javascriptapi/jsobjectwrap.test.ets @@ -45,11 +45,11 @@ export default function abilityTestJsObjectWrap() { let ret: testNapi.testNapiWrap = new testNapi.testNapiWrap(); hilog.info(0x0000, 'testTag', `type of napi_wrap() is = ${typeof (ret)}`); expect(typeof (ret)).assertEqual('object'); + let ret1 = ret.Tyof(''); hilog.info(0x0000, 'testTag', `type of ret.Tyof('') is = ${typeof (ret1)}`); expect(ret1).assertEqual('string'); - let ret2 = ret.Tyof(false); hilog.info(0x0000, 'testTag', `type of ret.Tyof(false) is = ${typeof (ret2)}`); expect(ret2).assertEqual('boolean');