• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# app.js
2
3
4## Application Lifecycle
5
6You can customize the [lifecycle](../ui/js-framework-lifecycle.md) implementation logic on an application-by-application basis in app.js. The following example only prints the corresponding logs in the lifecycle function:
7
8```js
9// app.js
10export default {
11    onCreate() {
12        console.info('Application onCreate');
13    },
14
15    onDestroy() {
16        console.info('Application onDestroy');
17    },
18}
19```
20
21## Application Object<sup>6+</sup>
22
23| Attribute | Data Type | Description |
24| -------- | -------- | -------- |
25| getApp | Function | Obtains the object exposed in the **app.js** file from the custom .js file. |
26
27The following is a sample code snippet:
28
29```js
30// app.js
31export default {
32    data: {
33        test: "by getAPP"
34    },
35    onCreate() {
36        console.info('AceApplication onCreate');
37    },
38    onDestroy() {
39        console.info('AceApplication onDestroy');
40    },
41};
42```
43
44
45```js
46// test.js Customize the logic code.
47export var appData = getApp().data;
48```
49