1 | # Vant Touch Emulator
|
2 |
|
3 | 在桌面端上模拟移动端 touch 事件,实现方式来自于 [hammerjs/touchemulator](https://github.com/hammerjs/touchemulator).
|
4 |
|
5 | ## Install
|
6 |
|
7 | ```shell
|
8 | # with npm
|
9 | npm i @vant/touch-emulator
|
10 |
|
11 | # with yarn
|
12 | yarn add @vant/touch-emulator
|
13 |
|
14 | # with pnpm
|
15 | pnpm add @vant/touch-emulator
|
16 | ```
|
17 |
|
18 | ## 使用指南
|
19 |
|
20 | 直接在代码中引入模块即可,模块会自动完成初始化并生效
|
21 |
|
22 | ```js
|
23 | import '@vant/touch-emulator';
|
24 | ```
|
25 |
|
26 | ## CDN 引入
|
27 |
|
28 | ```html
|
29 | <script src="https://fastly.jsdelivr.net/npm/@vant/touch-emulator"></script>
|
30 | ```
|
31 |
|
32 | ## 禁用 touch 模拟
|
33 |
|
34 | 在标签上添加 `data-no-touch-simulate` 属性后,可以使这个标签(以及它的子元素)不触发 `touch` 模拟事件。
|
35 |
|
36 | ```html
|
37 | <div data-no-touch-simulate />
|
38 | ```
|