> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# pointer-events

APISummary
## 介绍

CSS 属性 `pointer-events` 指定元件是否能够响应触摸事件。

## 使用示例

**下面是一个示例: css-api**

**Entry:** `src/pointer-events`
**Bundle:** `dist/pointer-events.lynx.bundle`

```tsx
import { root, useState } from "@lynx-js/react";
import type { TouchEvent } from "@lynx-js/types";
import "./index.scss";

const PointerEvents = () => {
  const [bgColor, setBgColor] = useState("white");
  const [isShow, setIsShow] = useState(false);

  function handleControlTap(e: TouchEvent) {
    "background-only";
    setIsShow(isShow => !isShow);
  }

  function handleContentTap(e: TouchEvent) {
    "background-only";
    const rndCol = `rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${
      Math.floor(Math.random() * 256)
    })`;
    setBgColor(rndCol);
  }

  return (
    <view className="container">
      <view className="control" bindtap={handleControlTap}>
        <text style={{ fontSize: "18px" }}>show or close popup</text>
      </view>
      {isShow
        && (
          <view className="popup" style={{ pointerEvents: "none" }}>
            <view className="mask">
              <view
                className="content"
                style={{ backgroundColor: bgColor, pointerEvents: "auto" }}
                bindtap={handleContentTap}
              />
            </view>
          </view>
        )}
    </view>
  );
};

root.render(<PointerEvents />);

```

v0.11.0



## 语法

```css
pointer-events: auto;
pointer-events: none;
```

### 取值

- `auto`

  默认值，此时，节点可以响应触摸事件。

- `none`

  节点不能响应触摸事件。

## 形式定义

| 初始值 | auto |
| 适用元素 | all elements that don't override hitTest |
| 是否支持继承 | no |
| 是否支持动画 | no |


## 形式语法

```
pointer-events: auto | none;
```

## 与 Web 的区别

不支持 `inherit`、`initial` 和 `unset`，不存在 `visiblePaintedroll`、 `visibleFill` 等 `SVG only` 的属性值。

## 注意事项

- 该属性有继承效果，即当子节点没有设置 `pointer-events` 时，会继承父节点的 `pointer-events` 值。

## 兼容性

**Compatibility Table**

**Query:** `css.properties.pointer-events`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/225-pointer-events.json) · [MDN](https://developer.mozilla.org/zh-CN/docs/Web/CSS/pointer-events)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| pointer-events | Yes (3.5) | Yes (3.5) | Yes (3.5) | Yes (1.0) | Yes (1.0) | Yes |

**`pointer-events`**

**Specifications:**

