我按照文档新建了MyAbilityStage,并且在该模块对应的 module.json5中配置如下,但是在预览启动时,log控制台没打印,求解惑
代码如下
import AbilityStage from '@ohos.app.ability.AbilityStage';
export default class MyAbilityStage extends AbilityStage{
onCreate(): void {
console.log("MyAbilityStage onCreate")
}
}
module.json5 如下
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "MyAbilityStage",
"srcEntry": "./ets/myabilitystage/MyAbilityStage.ets",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"launchType": "singleton",
"name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
求解惑
已解决 仅预览模式不会触犯,需要模拟器启动才可以