小编siv*_*thi的帖子

忽略尝试使用 cancelable=false 取消 touchmove 事件,例如因为滚动正在进行且不能被中断

当我使用 antd 抽屉时。在里面,我正在使用“ui li ul”标签。对于那个“ul”滚动条只能工作停止它甚至不适用于手机和平板电脑

componentWillUpdate() {
    window.addEventListener("touchmove", ontouchmove);
    function ontouchmove(e) {

      if (e.cancelable) {
        e.preventDefault();
        e.stopPropagation();
        return false;

      }
    }
}
Run Code Online (Sandbox Code Playgroud)

import React from "react";
import "antd/dist/antd.css";
import "./index.css";
import { Drawer, Button } from "antd";

class App extends React.Component {
  state = { visible: false };

  componentWillUpdate() {
    window.addEventListener("touchmove", ontouchmove);
    function ontouchmove(e) {

      if (e.cancelable) {
        e.preventDefault();
        e.stopPropagation();
        return false;

      }
    }
  }

  showDrawer = (e) => {
    this.setState({
      visible: true
    });
  };

  onClose = (e) => { …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs antd

6
推荐指数
1
解决办法
785
查看次数

标签 统计

antd ×1

javascript ×1

reactjs ×1