diff --git a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md index 3284f0899bdf2e2f3c3a269f349c8383184a923a..51c857fc8bfc18b193f5121c2c51e739ca757f65 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -17,7 +17,7 @@ ## 导入模块 -```js +```ts import backgroundTaskManager from '@ohos.backgroundTaskManager'; ``` @@ -47,7 +47,7 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen **示例**: - ```js + ```ts import backgroundTaskManager from '@ohos.backgroundTaskManager'; let myReason = 'test requestSuspendDelay'; @@ -79,11 +79,11 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): **示例**: - ```js + ```ts import backgroundTaskManager from '@ohos.backgroundTaskManager'; let delayInfo = backgroundTaskManager.requestSuspendDelay("test", () => {}); - backgroundTaskManager.getRemainingDelayTime(delayInfo.requestId, (err, res) => { + backgroundTaskManager.getRemainingDelayTime(delayInfo.requestId, (err: BusinessError, res: number) => { if(err) { console.log('callback => Operation getRemainingDelayTime failed. Cause: ' + err.code); } else { @@ -115,7 +115,7 @@ getRemainingDelayTime(requestId: number): Promise<number> **示例**: -```js +```ts let delayInfo = backgroundTaskManager.requestSuspendDelay("test", () => {}); backgroundTaskManager.getRemainingDelayTime(delayInfo.requestId).then((res:number) => { console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res)); @@ -141,7 +141,7 @@ cancelSuspendDelay(requestId: number): void **示例**: - ```js + ```ts let delayInfo = backgroundTaskManager.requestSuspendDelay("test", () => {}); backgroundTaskManager.cancelSuspendDelay(delayInfo.requestId); ``` @@ -267,7 +267,7 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **示例**: -FA模型示例: +FA模型示例(需使用js代码开发): ```js import backgroundTaskManager from '@ohos.backgroundTaskManager'; @@ -348,7 +348,7 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo **示例**: -FA模型示例: +FA模型示例(需使用js代码开发): ```js import backgroundTaskManager from '@ohos.backgroundTaskManager'; diff --git a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md index 8232aa366630f12ff418d461f01b8ed3c58b428d..9fbbd64c6308c7fe1d5fd3ff005397f76e38548f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @@ -9,7 +9,7 @@ ## 导入模块 -```js +```ts import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; ``` @@ -53,22 +53,23 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen **示例**: - ```js - import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +```ts +import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +import { BusinessError } from '@ohos.base'; - let myReason = 'test requestSuspendDelay'; - try { - let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { - console.info("Request suspension delay will time out."); - }) - let id = delayInfo.requestId; - let time = delayInfo.actualDelayTime; - console.info("The requestId is: " + id); - console.info("The actualDelayTime is: " + time); - } catch (error) { - console.error(`requestSuspendDelay failed. code is ${error.code} message is ${error.message}`); - } - ``` +let myReason = 'test requestSuspendDelay'; +try { +let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => { + console.info("Request suspension delay will time out."); +}) +let id = delayInfo.requestId; +let time = delayInfo.actualDelayTime; +console.info("The requestId is: " + id); +console.info("The actualDelayTime is: " + time); +} catch (error) { +console.error(`requestSuspendDelay failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); +} +``` ## backgroundTaskManager.getRemainingDelayTime @@ -102,22 +103,19 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): **示例**: - ```js - import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +```ts +import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +import { BusinessError } from '@ohos.base'; - let id = 1; - try { - backgroundTaskManager.getRemainingDelayTime(id, (error, res) => { - if(error) { - console.error(`callback => Operation getRemainingDelayTime failed. code is ${error.code} message is ${error.message}`); - } else { - console.log('callback => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res)); - } - }) - } catch (error) { - console.error(`callback => Operation getRemainingDelayTime failed. code is ${error.code} message is ${error.message}`); - } - ``` +let id = 1; +backgroundTaskManager.getRemainingDelayTime(id, (error: BusinessError, res: number) => { + if(error) { + console.error(`callback => Operation getRemainingDelayTime failed. code is ${error.code} message is ${error.message}`); + } else { + console.log('callback => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res)); + } +}) +``` ## backgroundTaskManager.getRemainingDelayTime @@ -155,20 +153,17 @@ getRemainingDelayTime(requestId: number): Promise<number> **示例**: - ```js - import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +```ts +import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +import { BusinessError } from '@ohos.base'; - let id = 1; - try { - backgroundTaskManager.getRemainingDelayTime(id).then( res => { - console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res)); - }).catch( error => { - console.error(`promise => Operation getRemainingDelayTime failed. code is ${error.code} message is ${error.message}`); - }) - } catch (error) { +let id = 1; +backgroundTaskManager.getRemainingDelayTime(id).then((res: number) => { + console.log('promise => Operation getRemainingDelayTime succeeded. Data: ' + JSON.stringify(res)); +}).catch((error: BusinessError) => { console.error(`promise => Operation getRemainingDelayTime failed. code is ${error.code} message is ${error.message}`); - } - ``` +}) +``` ## backgroundTaskManager.cancelSuspendDelay @@ -202,12 +197,13 @@ cancelSuspendDelay(requestId: number): void ```js import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; + import { BusinessError } from '@ohos.base'; let id = 1; try { backgroundTaskManager.cancelSuspendDelay(id); } catch (error) { - console.error(`cancelSuspendDelay failed. code is ${error.code} message is ${error.message}`); + console.error(`cancelSuspendDelay failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } ``` @@ -249,9 +245,10 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want ```js import UIAbility from '@ohos.app.ability.UIAbility'; import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; -import wantAgent from '@ohos.app.ability.wantAgent'; +import wantAgent, { WantAgent } from '@ohos.app.ability.wantAgent'; +import { BusinessError } from '@ohos.base'; -function callback(error, data) { +function callback(error: BusinessError, data: void) { if (error) { console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`); } else { @@ -260,8 +257,8 @@ function callback(error, data) { } export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - let wantAgentInfo = { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + let wantAgentInfo: wantAgent.WantAgentInfo = { wants: [ { bundleName: "com.example.myapplication", @@ -274,16 +271,16 @@ export default class EntryAbility extends UIAbility { }; try { - wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj: WantAgent) => { try { backgroundTaskManager.startBackgroundRunning(this.context, backgroundTaskManager.BackgroundMode.LOCATION, wantAgentObj, callback) } catch (error) { - console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + console.error(`Operation startBackgroundRunning failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } }); } catch (error) { - console.error(`Operation getWantAgent failed. code is ${error.code} message is ${error.message}`); + console.error(`Operation getWantAgent failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } } }; @@ -332,11 +329,12 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want ```js import UIAbility from '@ohos.app.ability.UIAbility'; import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; -import wantAgent from '@ohos.app.ability.wantAgent'; +import wantAgent, { WantAgent } from '@ohos.app.ability.wantAgent'; +import { BusinessError } from '@ohos.base'; export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { - let wantAgentInfo = { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + let wantAgentInfo: wantAgent.WantAgentInfo = { wants: [ { bundleName: "com.example.myapplication", @@ -349,20 +347,20 @@ export default class EntryAbility extends UIAbility { }; try { - wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj: WantAgent) => { try { backgroundTaskManager.startBackgroundRunning(this.context, backgroundTaskManager.BackgroundMode.LOCATION, wantAgentObj).then(() => { console.info("Operation startBackgroundRunning succeeded"); - }).catch((error) => { + }).catch((error: BusinessError) => { console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`); }); } catch (error) { - console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + console.error(`Operation startBackgroundRunning failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } }); } catch (error) { - console.error(`Operation getWantAgent failed. code is ${error.code} message is ${error.message}`); + console.error(`Operation getWantAgent failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } } }; @@ -402,8 +400,9 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo ```js import UIAbility from '@ohos.app.ability.UIAbility'; import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +import { BusinessError } from '@ohos.base'; -function callback(error, data) { +function callback(error: BusinessError, data: void) { if (error) { console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); } else { @@ -412,11 +411,11 @@ function callback(error, data) { } export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { try { backgroundTaskManager.stopBackgroundRunning(this.context, callback); } catch (error) { - console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + console.error(`Operation stopBackgroundRunning failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } } }; @@ -461,17 +460,18 @@ stopBackgroundRunning(context: Context): Promise<void> ```js import UIAbility from '@ohos.app.ability.UIAbility'; import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +import { BusinessError } from '@ohos.base'; export default class EntryAbility extends UIAbility { - onCreate(want, launchParam) { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { try { backgroundTaskManager.stopBackgroundRunning(this.context).then(() => { console.info("Operation stopBackgroundRunning succeeded"); - }).catch((error) => { + }).catch((error: BusinessError) => { console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); }); } catch (error) { - console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + console.error(`Operation stopBackgroundRunning failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } } }; @@ -510,8 +510,9 @@ applyEfficiencyResources(request: EfficiencyResourcesRequest): void ```js import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +import { BusinessError } from '@ohos.base'; -let request = { +let request: backgroundTaskManager.EfficiencyResourcesRequest = { resourceTypes: backgroundTaskManager.ResourceType.CPU, isApply: true, timeOut: 0, @@ -523,7 +524,7 @@ try { backgroundTaskManager.applyEfficiencyResources(request); console.info("applyEfficiencyResources success. "); } catch (error) { - console.error(`applyEfficiencyResources failed. code is ${error.code} message is ${error.message}`); + console.error(`applyEfficiencyResources failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md index 70a2c5ef5456631a403c756e9a2fdfae38194897..4cf176b101a9191d34825cae2657aa0291dfd612 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md @@ -10,7 +10,7 @@ ## 导入模块 -```js +```ts import workScheduler from '@ohos.resourceschedule.workScheduler'; ``` @@ -42,8 +42,8 @@ startWork(work: WorkInfo): void **示例**: -```js - let workInfo = { +```ts + let workInfo: workScheduler.WorkInfo = { workId: 1, batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, isRepeat: false, @@ -61,7 +61,7 @@ startWork(work: WorkInfo): void workScheduler.startWork(workInfo); console.info('workschedulerLog startWork success'); } catch (error) { - console.error(`workschedulerLog startwork failed. code is ${error.code} message is ${error.message}`); + console.error(`workschedulerLog startwork failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } ``` @@ -93,8 +93,8 @@ stopWork(work: WorkInfo, needCancel?: boolean): void **示例**: -```js - let workInfo = { +```ts + let workInfo: workScheduler.WorkInfo = { workId: 1, batteryStatus:workScheduler.BatteryStatus.BATTERY_STATUS_LOW, isRepeat: false, @@ -112,7 +112,7 @@ stopWork(work: WorkInfo, needCancel?: boolean): void workScheduler.stopWork(workInfo, false); console.info('workschedulerLog stopWork success'); } catch (error) { - console.error(`workschedulerLog stopWork failed. code is ${error.code} message is ${error.message}`); + console.error(`workschedulerLog stopWork failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } ``` @@ -144,20 +144,14 @@ getWorkStatus(workId: number, callback : AsyncCallback\): void **示例**: -```js - try{ - workScheduler.getWorkStatus(50, (error, res) => { - if (error) { - console.error(`workschedulerLog getWorkStatus failed. code is ${error.code} message is ${error.message}`); - } else { - for (let item in res) { - console.info(`workschedulerLog getWorkStatus success, ${item} is: ${res[item]}`); - } - } - }); - } catch (error) { - console.error(`workschedulerLog getWorkStatus failed. code is ${error.code} message is ${error.message}`); - } +```ts + workScheduler.getWorkStatus(50, (error: BusinessError, res: workScheduler.WorkInfo) => { + if (error) { + console.error(`workschedulerLog getWorkStatus failed. code is ${error.code} message is ${error.message}`); + } else { + console.info(`workschedulerLog getWorkStatus success, ${JSON.stringify(res)}`); + } + }); ``` ## workScheduler.getWorkStatus @@ -193,18 +187,12 @@ getWorkStatus(workId: number): Promise\ **示例**: -```js - try{ - workScheduler.getWorkStatus(50).then((res) => { - for (let item in res) { - console.info(`workschedulerLog getWorkStatus success, ${item} is: ${res[item]}`); - } - }).catch((error) => { - console.error(`workschedulerLog getWorkStatus failed. code is ${error.code} message is ${error.message}`); - }) - } catch (error) { +```ts + workScheduler.getWorkStatus(50).then((res: workScheduler.WorkInfo) => { + console.info(`workschedulerLog getWorkStatus success, ${JSON.stringify(res)}`); + }).catch((error: BusinessError) => { console.error(`workschedulerLog getWorkStatus failed. code is ${error.code} message is ${error.message}`); - } + }) ``` ## workScheduler.obtainAllWorks @@ -239,18 +227,14 @@ obtainAllWorks(callback : AsyncCallback\): Array\ **示例**: -```js - try{ - workScheduler.obtainAllWorks((error, res) =>{ - if (error) { - console.error(`workschedulerLog obtainAllWorks failed. code is ${error.code} message is ${error.message}`); - } else { - console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`); - } - }); - } catch (error) { - console.error(`workschedulerLog obtainAllWorks failed. code is ${error.code} message is ${error.message}`); - } +```ts + workScheduler.obtainAllWorks((error: BusinessError, res: Array) =>{ + if (error) { + console.error(`workschedulerLog obtainAllWorks failed. code is ${error.code} message is ${error.message}`); + } else { + console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`); + } + }); ``` ## workScheduler.obtainAllWorks @@ -279,16 +263,12 @@ obtainAllWorks(): Promise\> **示例**: -```js - try{ - workScheduler.obtainAllWorks().then((res) => { - console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`); - }).catch((error) => { - console.error(`workschedulerLog obtainAllWorks failed. code is ${error.code} message is ${error.message}`); - }) - } catch (error) { +```ts + workScheduler.obtainAllWorks().then((res: Array) => { + console.info(`workschedulerLog obtainAllWorks success, data is: ${JSON.stringify(res)}`); + }).catch((error: BusinessError) => { console.error(`workschedulerLog obtainAllWorks failed. code is ${error.code} message is ${error.message}`); - } + }) ``` ## workScheduler.stopAndClearWorks @@ -311,12 +291,12 @@ stopAndClearWorks(): void **示例**: -```js +```ts try{ workScheduler.stopAndClearWorks(); console.info(`workschedulerLog stopAndClearWorks success`); } catch (error) { - console.error(`workschedulerLog stopAndClearWorks failed. code is ${error.code} message is ${error.message}`); + console.error(`workschedulerLog stopAndClearWorks failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } ``` @@ -354,18 +334,14 @@ isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean **示例**: -```js - try{ - workScheduler.isLastWorkTimeOut(500, (error, res) =>{ - if (error) { - console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`); - } else { - console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`); - } - }); - } catch (error) { - console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`); - } +```ts + workScheduler.isLastWorkTimeOut(500, (error: BusinessError, res: boolean) =>{ + if (error) { + console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`); + } else { + console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`); + } + }); ``` ## workScheduler.isLastWorkTimeOut @@ -401,18 +377,14 @@ isLastWorkTimeOut(workId: number): Promise\ **示例**: -```js - try{ - workScheduler.isLastWorkTimeOut(500) - .then(res => { - console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`); - }) - .catch(error => { - console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`); - }); - } catch (error) { - console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`); - } +```ts + workScheduler.isLastWorkTimeOut(500) + .then((res: boolean) => { + console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`); + }) + .catch((error: BusinessError) => { + console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`); + }); ``` ## WorkInfo diff --git a/zh-cn/application-dev/task-management/continuous-task.md b/zh-cn/application-dev/task-management/continuous-task.md index 70cf3617e06d706bf782e1b2db14358b5ce5fb6a..58fe36dad796cbc5a2b9730f0fc1b7966c71aae4 100644 --- a/zh-cn/application-dev/task-management/continuous-task.md +++ b/zh-cn/application-dev/task-management/continuous-task.md @@ -103,7 +103,7 @@ private context: Context = getContext(this); startContinuousTask() { - let wantAgentInfo: wantAgent.wantAgentInfo = { + let wantAgentInfo: wantAgent.WantAgentInfo = { // 点击通知后,将要执行的动作列表 wants: [ { @@ -353,7 +353,7 @@ import { BusinessError } from '@ohos.base'; ``` -4. 申请和取消长时任务。在 ServiceAbility 中,调用 startBackgroundRunning() 接口和 startBackgroundRunning() 接口实现长时任务的申请和取消。 +4. 申请和取消长时任务。在 ServiceAbility 中,调用 startBackgroundRunning() 接口和 startBackgroundRunning() 接口实现长时任务的申请和取消,通过js代码实现。 ```js function startContinuousTask() { diff --git a/zh-cn/application-dev/task-management/work-scheduler.md b/zh-cn/application-dev/task-management/work-scheduler.md index 151854ae89fdd2cfe5e25900b33e89ca72b39abe..24504b1f763c91e250da3b72271db01d1115e2ac 100644 --- a/zh-cn/application-dev/task-management/work-scheduler.md +++ b/zh-cn/application-dev/task-management/work-scheduler.md @@ -121,7 +121,7 @@ WorkInfo参数用于设置应用条件,参数设置时需遵循以下规则: ```ts import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility'; - import workScheduler fron '@ohos.resourceschedule.workScheduler'; + import workScheduler from '@ohos.resourceschedule.workScheduler'; ``` 3. 实现WorkSchedulerExtension生命周期接口。 @@ -184,8 +184,8 @@ WorkInfo参数用于设置应用条件,参数设置时需遵循以下规则: try { workScheduler.startWork(this.workInfo); console.info(`startWork success`); - } catch (error: BusinessError) { - console.error(`startWork failed. code is ${error.code} message is ${error.message}`); + } catch (error) { + console.error(`startWork failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } ``` @@ -202,8 +202,8 @@ WorkInfo参数用于设置应用条件,参数设置时需遵循以下规则: try { workScheduler.stopWork(this.workInfo); console.info(`stopWork success`); - } catch (error: BusinessError) { - console.error(`stopWork failed. code is ${error.code} message is ${error.message}`); + } catch (error) { + console.error(`stopWork failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); } ```