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

!22974 api接口文档示例代码修改

Merge pull request !22974 from zcl/master
...@@ -107,12 +107,23 @@ deleteCalendar(calendar: Calendar, callback: AsyncCallback\<void>): void ...@@ -107,12 +107,23 @@ deleteCalendar(calendar: Calendar, callback: AsyncCallback\<void>): void
**示例** **示例**
```js ```js
calendarManager.deleteCalendar(specificCalendar, (err) => { const calendarAccount: calendarManager.CalendarAccount = {
name: 'MyCalendar',
type: calendarManager.CalendarType.LOCAL
};
calendarManager.getCalendar(calendarAccount, (err, data) => {
if (err) {
console.error("Failed to get calendar");
} else {
console.info("Succeeded in getting calendar");
calendarManager.deleteCalendar(data, (err) => {
if (err) { if (err) {
console.error("Failed to delete calendar"); console.error("Failed to delete calendar");
} else { } else {
console.info("Succeeded in deleting calendar"); console.info("Succeeded in deleting calendar");
} }
});
}
}); });
``` ```
...@@ -141,10 +152,19 @@ deleteCalendar(calendar: Calendar): Promise\<void> ...@@ -141,10 +152,19 @@ deleteCalendar(calendar: Calendar): Promise\<void>
**示例** **示例**
```js ```js
calendarManager.deleteCalendar(specificCalendar).then(() => { const calendarAccount: calendarManager.CalendarAccount = {
console.error("Succeeded in deleting calendar"); name: 'MyCalendar',
type: calendarManager.CalendarType.LOCAL
};
calendarManager.getCalendar(calendarAccount).then((data) => {
console.info("Succeeded in getting calendar");
calendarManager.deleteCalendar(data).then(() => {
console.info("Succeeded in deleting calendar");
}).catch((err) => {
console.error("Failed to delete calendar");
});
}).catch((err) => { }).catch((err) => {
console.info("Failed to delete calendar"); console.error("Failed to get calendar");
}); });
``` ```
...@@ -199,6 +219,10 @@ getCalendar(calendarAccount: CalendarAccount, callback: AsyncCallback\<Calendar> ...@@ -199,6 +219,10 @@ getCalendar(calendarAccount: CalendarAccount, callback: AsyncCallback\<Calendar>
```js ```js
let calendar = null; let calendar = null;
const calendarAccount: calendarManager.CalendarAccount = {
name: 'MyCalendar',
type: calendarManager.CalendarType.LOCAL
};
calendarManager.getCalendar(calendarAccount, (err, data) => { calendarManager.getCalendar(calendarAccount, (err, data) => {
if (err) { if (err) {
console.error("Failed to get calendar"); console.error("Failed to get calendar");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册