如何使用iframe在PC端模拟出手机环境

1,026 阅读1分钟

image.png

列子:我左边是一个ifream加载的h5网页,里面的touch事件只有在h5里面有效,但是ifream又不可能像浏览器一样进行H5的展示,那我又不想为pc单独写一个事件,怎么办呢?(如下)

image.png

可以参考这个回答: github.com/ant-design/…

使用的是如下的库 github.com/hammerjs/to… 使用起来也很简单,

// 在jsx 或者 tsx 中引入
import TouchEmulator from 'hammer-touchemulator';
new TouchEmulator();