参考:https://www.jianshu.com/p/53f64ea1de4f
首先需要安装hammerjs ,在项目目录下执行:
npm install hammerjs --save
在项目的src/main.ts 中引入hammerjs:
import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; import 'hammerjs'; if (environment.production) { enableProdMode(); } platformBrowserDynamic().bootstrapModule(AppModule) .catch(err => console.log(err));