小编Non*_*niq的帖子

JavaScript按类名获取所有元素,同时排除特定类?

所以我想说我有以下网站:

<div class="hello"></div>
<div class="hello"></div>
<div class="hello world"></div>
<div class="hello"></div>
Run Code Online (Sandbox Code Playgroud)

使用以下代码,我将所有具有"hello"类的元素保存到数组中:

var inputs = document.getElementsByClassName('hello');

有什么方法可以排除所有具有"世界"类的元素,所以我只能获得三个结果吗?

html javascript

3
推荐指数
2
解决办法
3984
查看次数

TypeError:存储库方法不是函数(NestJS / TypeORM)

我正在使用 NestJS 和 TypeORM。尝试调用存储库的 createMailLogEntry 方法时,出现以下错误:TypeError: this.mailLogEntryRepository.createMailLogEntry is not a function

我无法弄清楚出了什么问题。

mailing.service.ts

@Injectable()
export class MailingService {

    constructor(@InjectRepository(MailLogEntryRepository) private mailLogEntryRepository: MailLogEntryRepository) { }

        // ...

        if(transferResult) {
            await this.mailLogEntryRepository.createMailLogEntry({
                creationDate: new Date(Date.now()),
                from: mailContent.from,
                to: mailContent.to,
                subject: mailContent.subject,
                text: mailContent.text,
                html: mailContent.html,
                cc: mailContent.cc,
                bcc: mailContent.bcc,
            });
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

邮件日志条目.repository.ts

@EntityRepository(MailLogEntry)
export class MailLogEntryRepository extends Repository<MailLogEntry> {

    async createMailLogEntry(mailLogEntryDto: MailLogEntryDto): Promise<MailLogEntry> {
        const mailLogEntry = MailLogEntryRepository.createMailLogEntryFromDto(mailLogEntryDto);
        return await mailLogEntry.save();
    }

    private static createMailLogEntryFromDto(mailLogEntryDto: MailLogEntryDto): MailLogEntry {
        const …
Run Code Online (Sandbox Code Playgroud)

javascript node.js typescript typeorm nestjs

1
推荐指数
3
解决办法
3860
查看次数

标签 统计

javascript ×2

html ×1

nestjs ×1

node.js ×1

typeorm ×1

typescript ×1