openharmony 鸿蒙 js-framework-js-file

2022-08-09 浏览 (911)

app.js

Application Lifecycle

You can customize the lifecycle implementation logic on an application-by-application basis in app.js. The following example only prints the corresponding logs in the lifecycle function:

// app.js
export default {
    onCreate() {
        console.info('Application onCreate');
    },

    onDestroy() {
        console.info('Application onDestroy');
    },
}

Application Object6+

AttributeData TypeDescription
getAppFunctionObtains the object exposed in the app.js file from the custom .js file.

The following is a sample code snippet:

// app.js
export default {
    data: {
        test: "by getAPP"
    },
    onCreate() {
        console.info('AceApplication onCreate');
    },
    onDestroy() {
        console.info('AceApplication onDestroy');
    },
};
// test.js Customize the logic code.
export var appData = getApp().data;

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkUI

harmony 鸿蒙Atomic Service Full Screen Launch Component (FullScreenLaunchComponent)

harmony 鸿蒙Arc Button (ArcButton)

harmony 鸿蒙Animation Smoothing

harmony 鸿蒙Animation Overview

harmony 鸿蒙Frame Animation (ohos.animator)

harmony 鸿蒙Implementing Property Animation

harmony 鸿蒙Property Animation Overview

harmony 鸿蒙Dialog Box Overview

harmony 鸿蒙Blur Effect

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/8fac1f182a0e4531a245bed6fee3ee15