简体   繁体   English

我如何在 Ionic 中使用hammerjs

[英]How do I use hammerjs with Ionic

I am trying to using hammer js in ionic angular project.我正在尝试在 ionic angular 项目中使用hammer js。

I have imported hammermodule in my component's module:我在组件的模块中导入了hammermodule:

import { BrowserModule, HammerModule } from '@angular/platform-browser';
//...
@NgModule({
  imports: [
BrowserModule,
HammerModule,
//...
]})

And imported hammerjs inside the component as per docs.并根据文档在组件内导入了hammerjs。 But no event is triggered.但是没有触发事件。

<div (swipeleft)="onswipe(i)">swipe me</div>
onswipe(x){
console.log(x,'triggered')
}

HammerModule should be imported inside AppModule(not inside child modules). HammerModule 应该被导入到 AppModule 中(而不是在子模块中)。

You can import 'hammerjs' inside the components.您可以在组件内导入“hammerjs”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM