【问题标题】:How do I use hammerjs with Ionic如何将hammerjs与Ionic一起使用
【发布时间】:2021-12-12 17:33:26
【问题描述】:

我正在尝试在离子角度项目中使用锤子 js。

我在组件的模块中导入了锤子模块:

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

并根据文档在组件内导入了hammerjs。但是没有触发任何事件。

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

【问题讨论】:

    标签: angular ionic-framework hammer.js


    【解决方案1】:

    HammerModule 应该在 AppModule 中导入(而不是在子模块中)。

    您可以在组件中导入“hammerjs”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-07
      • 1970-01-01
      • 2018-12-06
      • 1970-01-01
      • 2016-12-31
      • 1970-01-01
      • 2017-03-09
      • 2015-05-29
      相关资源
      最近更新 更多