From 8a3f9fef679e4547a52446f2d9b6a36456f37f2c Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Mon, 12 Jul 2021 17:14:12 +0800 Subject: [PATCH] chore(App): getBackgroundAudioManager --- .../service/api/context/getBackgroundAudioManager.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/uni-app-plus/src/service/api/context/getBackgroundAudioManager.ts b/packages/uni-app-plus/src/service/api/context/getBackgroundAudioManager.ts index 9faa2cfde..d1d8ea5a7 100644 --- a/packages/uni-app-plus/src/service/api/context/getBackgroundAudioManager.ts +++ b/packages/uni-app-plus/src/service/api/context/getBackgroundAudioManager.ts @@ -1,4 +1,4 @@ -import { extend } from '@vue/shared' +import { extend, capitalize } from '@vue/shared' import { defineSyncApi, API_GET_BACKGROUND_AUDIO_MANAGER, @@ -301,12 +301,10 @@ function onBackgroundAudioStateChange({ const onInitBackgroundAudioManager = /*#__PURE__*/ once(() => { eventNames.forEach((item) => { - const name = item[0].toUpperCase() + item.substr(1) - BackgroundAudioManager.prototype[`on${name}` as onEventNames] = function ( - callback: Function - ) { - callbacks[item].push(callback) - } + BackgroundAudioManager.prototype[`on${capitalize(item)}` as onEventNames] = + function (callback: Function) { + callbacks[item].push(callback) + } }) }) -- GitLab