我找不到如何播放用户刚刚通过输入选择的音频文件。我有以下输入:
<input type='file' id="audio-input" class="audio-input" name="audio" accept=".mp3, .wav"/>
Run Code Online (Sandbox Code Playgroud)
我想在用户选择音频文件时显示该文件,以便他可以播放它。它会是这样的:
('#audio-input-0').change( function () {
let audio =
"<audio controls>" +
" <source id='audioFile' type='audio/mpeg'>" +
" Your browser does not support the audio element." +
"</audio>";
$('body').append(audio);
$('#audioFile').attr('src', $(this).val());
});
Run Code Online (Sandbox Code Playgroud)
我希望你明白我想要做什么,我真的不知道如何解释它(也许这就是为什么我在其他主题上找不到任何答案)。
在 NestJS API 上,我想在实体中使用模块服务,以使用非数据库属性填充该实体。
就我而言,我想获取我正在检索的类别的文章数量。
@Entity({ name: 'categories' })
export class Category {
constructor(private readonly service: CategoriesService) { }
@PrimaryGeneratedColumn()
id: number;
@Column()
@Index({ unique: true })
title: string;
@OneToMany(() => Article, articles => articles.category)
articles: Article[];
numberOfExercices: number;
@AfterLoad()
async countExercices() {
this.numberOfExercices = await this.service.getNumberOfArticles(this.id);
}
}
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误:
Nest can't resolve dependencies of the GlobalPrevCategoriesService (GlobalPrevCategoriesRepository, ?).
Please make sure that the argument dependency at index [1] is available in the GlobalPrevCategoriesModule context.
Run Code Online (Sandbox Code Playgroud)
我尝试了这个小变体,但遇到了同样的错误。
Nest can't resolve dependencies …Run Code Online (Sandbox Code Playgroud)