uniapp はオーディオ再生を停止するページにジャンプします

要件: ページにジャンプするときに再生中の音声を終了する

実装;

1:uniapp公式API

uni.addInterceptor('navigateTo', { //监听跳转的方式
				success: (e) => {
//voicePath为音频路径
					innerAudioContext.src = this.voicePath;
//stop()停止
					innerAudioContext.stop();
				}
			})



//其余跳转方式:
'redirectTo', //监听关闭本页面跳转
'switchTab',  //监听tabBar跳转
'navigateBack', //监听返回

2: Vue のライフサイクル

onUnload() {
//随便给个值来赋值,不然会报错,也可以赋值路径
            innerAudioContext.src = '1111111'
//关闭
			innerAudioContext.stop();
			
		},

おすすめ

転載: blog.csdn.net/m0_72196169/article/details/130843683