点击链接后,我正在尝试播放声音
这就是我所拥有的,但是,当我将其添加到文件中时,它无法正常工作,并且似乎大大降低了浏览器的速度
HTML:
<a routerLinkActive="active" routerLink="/tomato2" class="tomato" (click)="playAudio()">
<img class="tomato_1" src="https://freepngimage.com/content/uploads/images/tomato-7866.png" />
</a>
TS:
import { Component } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'home',
templateUrl: './catalog.component.html'
})
export class CatalogViewComponent {
playAudio(){
let audio = new Audio();
audio.src = "http://www.schillmania.com/projects/soundmanager2/demo/mpc/audio/CHINA_1.mp3";
audio.load();
audio.play();
this.playAudio();
}
}