harmony 鸿蒙app.js
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+
Attribute | Data Type | Description |
---|---|---|
getApp | Function | Obtains 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 鸿蒙Property Animation APIs
harmony 鸿蒙Property Animation Overview
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦