gpt4 book ai didi

angular - 如何修复错误类型错误 : Class constructor HammerGestureConfig cannot be invoked without 'new'

转载 作者:搜寻专家 更新时间:2023-10-30 21:25:30 26 4
gpt4 key购买 nike

我在添加 ngx-gallery 时遇到问题。检查时出现错误错误类型错误:类构造函数 HammerGestureConfig 不能在没有“new”的情况下被调用

我已经在app.module中添加了hammerjs但是还是有问题

这是我的 app.module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule } from '@angular/forms';
import { BsDropdownModule, TabsModule } from 'ngx-bootstrap';
import { RouterModule } from '@angular/router';
import { appRoutes } from './routes';
import { AuthGuard } from './_guards/auth.guard';
import { AuthService } from './_services/auth.service';
import { ErrorInterceptorProvider } from './_services/error.interceptor';
import { AlertifyService } from './_services/alertify.service';
import { UserService } from './_services/user.service';
import { JwtModule } from '@auth0/angular-jwt';
import { MemberDetailResolver } from './_resolvers/member-detail.resolver';
import { MemberListResolver } from './_resolvers/member-list.resolver';
import { NgxGalleryModule } from 'ngx-gallery';


import { AppComponent } from './app.component';
import { NavComponent } from './nav/nav.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { RegisterComponent } from './register/register.component';
import { MemberListComponent } from './members/member-list/member-list.component';
import { ListComponent } from './list/list.component';
import { MessagesComponent } from './messages/messages.component';
import { MemberCardComponent } from './members/member-card/member-card.component';
import { MemberDetailComponent } from './members/member-detail/member-detail.component';

export function tokeGetter() {
return localStorage.getItem('token');
}

@NgModule({
declarations: [
AppComponent,
NavComponent,
DashboardComponent,
RegisterComponent,
MemberListComponent,
ListComponent,
MessagesComponent,
MemberCardComponent,
MemberDetailComponent
],
imports: [
BrowserModule,
HttpClientModule,
FormsModule,
BsDropdownModule.forRoot(),
TabsModule.forRoot(),
RouterModule.forRoot(appRoutes),
NgxGalleryModule,
JwtModule.forRoot({
config: {
tokenGetter: tokeGetter,
whitelistedDomains: ['192.168.100.6:5000'],
blacklistedRoutes: ['192.168.100.6:5000/api/auth']
}
})
],
providers: [
AuthService,
ErrorInterceptorProvider,
AlertifyService,
AuthGuard,
UserService,
MemberDetailResolver,
MemberListResolver
],

bootstrap: [AppComponent]
})
export class AppModule { }

我想在每个用户中显示照片,但是因为错误不能显示

最佳答案

有更好的方法来解决这个问题。

修改 app.module.ts 中的提供者

export class CustomHammerConfig extends HammerGestureConfig  {
overrides = {
pinch: { enable: false },
rotate: { enable: false }
};
}

并添加到提供者

providers: [
{
provide: HAMMER_GESTURE_CONFIG, useClass: CustomHammerConfig
}
]

关于angular - 如何修复错误类型错误 : Class constructor HammerGestureConfig cannot be invoked without 'new' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57099273/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com