未验证 提交 bf1f9910 编写于 作者: O openharmony_ci 提交者: Gitee

!1775 Done! 1634:修正方法的格式

Merge pull request !1775 from wusongqing/TR1634
# FormExtension # FormExtension
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides **FormExtension** APIs. Provides **FormExtension** APIs.
...@@ -42,14 +42,16 @@ Called to notify the widget provider that a **Form** instance (widget) has been ...@@ -42,14 +42,16 @@ Called to notify the widget provider that a **Form** instance (widget) has been
- Example - Example
``` ```
onCreate(want) { export default class MyFormExtension extends FormExtension {
console.log('FormExtension onCreate, want:' + want.abilityName); onCreate(want) {
let dataObj1 = { console.log('FormExtension onCreate, want:' + want.abilityName);
temperature:"11c", let dataObj1 = {
"time":"11:00" temperature:"11c",
}; "time":"11:00"
let obj1 = formBindingData.createFormBindingData(dataObj1); };
return obj1; let obj1 = formBindingData.createFormBindingData(dataObj1);
return obj1;
}
} }
``` ```
...@@ -68,8 +70,10 @@ Called to notify the widget provider that a temporary widget has been converted ...@@ -68,8 +70,10 @@ Called to notify the widget provider that a temporary widget has been converted
- Example - Example
``` ```
onCastToNormal(formId) { export default class MyFormExtension extends FormExtension {
console.log('FormExtension onCastToNormal, formId:' + formId); onCastToNormal(formId) {
console.log('FormExtension onCastToNormal, formId:' + formId);
}
} }
``` ```
...@@ -88,14 +92,16 @@ Called to notify the widget provider that a widget has been updated. After obtai ...@@ -88,14 +92,16 @@ Called to notify the widget provider that a widget has been updated. After obtai
- Example - Example
``` ```
onUpdate(formId) { export default class MyFormExtension extends FormExtension {
console.log('FormExtension onUpdate, formId:' + formId); onUpdate(formId) {
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); console.log('FormExtension onUpdate, formId:' + formId);
this.context.updateForm(formId, obj2) let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
.then((data)=>{ this.context.updateForm(formId, obj2)
console.log('FormExtension context updateForm, data:' + data); .then((data)=>{
}).catch((error) => { console.log('FormExtension context updateForm, data:' + data);
console.error('Operation updateForm failed. Cause: ' + error);}); }).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
}
} }
``` ```
...@@ -114,17 +120,19 @@ Called to notify the widget provider of the change of visibility. ...@@ -114,17 +120,19 @@ Called to notify the widget provider of the change of visibility.
- Example - Example
``` ```
onVisibilityChange(newStatus) { export default class MyFormExtension extends FormExtension {
console.log('FormExtension onVisibilityChange, newStatus:' + newStatus); onVisibilityChange(newStatus) {
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); console.log('FormExtension onVisibilityChange, newStatus:' + newStatus);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
for (let key in newStatus) {
console.log('FormExtension onVisibilityChange, key:' + key + ", value=" + newStatus[key]); for (let key in newStatus) {
this.context.updateForm(key, obj2) console.log('FormExtension onVisibilityChange, key:' + key + ", value=" + newStatus[key]);
.then((data)=>{ this.context.updateForm(key, obj2)
console.log('FormExtension context updateForm, data:' + data); .then((data)=>{
}).catch((error) => { console.log('FormExtension context updateForm, data:' + data);
console.error('Operation updateForm failed. Cause: ' + error);}); }).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
}
} }
} }
``` ```
...@@ -145,8 +153,10 @@ Called to instruct the widget provider to receive and process the widget event. ...@@ -145,8 +153,10 @@ Called to instruct the widget provider to receive and process the widget event.
- Example - Example
``` ```
onEvent(formId, message) { export default class MyFormExtension extends FormExtension {
console.log('FormExtension onEvent, formId:' + formId + ", message:" + message); onEvent(formId, message) {
console.log('FormExtension onEvent, formId:' + formId + ", message:" + message);
}
} }
``` ```
...@@ -165,7 +175,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been ...@@ -165,7 +175,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been
- Example - Example
``` ```
onDestroy(formId) { export default class MyFormExtension extends FormExtension {
console.log('FormExtension onDestroy, formId:' + formId); onDestroy(formId) {
console.log('FormExtension onDestroy, formId:' + formId);
}
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册