onWindowStageCreate 问题 - HarmonyOS 鸿蒙Next
onWindowStageCreate 问题 - HarmonyOS 鸿蒙Next
windowStage.loadContent(‘pages/Index’, (err, data) => {
if (err) {
hilog.error(0x0000, ‘testTag’, Failed to load the content. Code: ${err.code}, message: ${err.message}.
);
return;
}
hilog.info(0x0000, ‘testTag’, Succeeded in loading the content. Data: ${JSON.stringify(data)}.
);
});
这时候 data 不能确定是不是NULL值,程序会报错,应该怎么修改才能通过
更多关于onWindowStageCreate 问题 - HarmonyOS 鸿蒙Next的实战教程也可以访问 https://www.itying.com/category-93-b0.html
去掉 下面引用没问题了
import { JSON } from '@kit.ArkTS';
更多关于onWindowStageCreate 问题 - HarmonyOS 鸿蒙Next的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
报错:
hvigor ERROR: Failed :MyShUbing:default@CompileArkTS...
hvigor ERROR: ArkTS Compiler Error
1 ERROR: ArkTS:ERROR File: D:/harmony/Shubing/MyShUbing/src/main/ets/myshubingability/MyShUbingAbility.ets:48:95
No overload matches this call.
Overload 1 of 2, '(value: Object, replacer?: (string | number)[], space?: string | number): string', gave the following error.
Argument of type 'void' is not assignable to parameter of type 'Object'.
Overload 2 of 2, '(value: Object, replacer?: Transformer, space?: string | number): string', gave the following error.
Argument of type 'void' is not assignable to parameter of type 'Object'.
引用
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
import { JSON } from '@kit.ArkTS';
我的方法 提示
window.WindowStage.loadContent(path: string, callback: AsyncCallback<void, void>): void (+2 overloads)
试过可行?