# react-remove-scroll-bar 中文文档

规范地址：https://npmcn.com/package/react-remove-scroll-bar/

版本：2\.3\.8
npm 元数据更新时间：2024-12-15T02:08:28.827Z
中文译文更新时间：2026-11-05T15:54:16.666Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/react-remove-scroll-bar
原文对照：https://npmcn.com/package/react-remove-scroll-bar/?lang=original
项目主页：https://github.com/theKashey/react-remove-scroll-bar#readme
源码仓库：https://github.com/theKashey/react-remove-scroll-bar

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：24.9 kB，27 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=10
- 运行依赖：2 个
- peer 依赖：@types/react \*，react ^16\.8\.0 \|\| ^17\.0\.0 \|\| ^18\.0\.0 \|\| ^19\.0\.0
- 首次发布：2019-01-18T02:57:17.378Z
- 最新版本发布：2024-12-15T02:08:28.658Z
- 近 30 天下载量：302852838（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：20（近 12 个月 0 个）

## 中文简介

删除没有内容的正文卷轴 _摇摆_

## 安装

```sh
npm install react-remove-scroll-bar
```

也可以使用：`pnpm add react-remove-scroll-bar`、`yarn add react-remove-scroll-bar`、`bun add react-remove-scroll-bar`

## README

# 反应- 移动- 滚动- 栏

[![npm](https://img.shields.io/npm/v/react-remove-scroll-bar.svg)](https://www.npmjs.com/package/react-remove-scroll-bar) [![bundle size](https://badgen.net/bundlephobia/minzip/react-remove-scroll-bar)](https://bundlephobia.com/result?p=react-remove-scroll-bar) [![downloads](https://badgen.net/npm/dm/react-remove-scroll-bar)](https://www.npmtrends.com/react-remove-scroll-bar)

* * *

> v1+用于反应 15,v2+需要反应 16.8+

删除滚动条( 通过设置) `overflow: hidden` 并保留了卷轴条"gap".

读取 - 它只是使卷轴条隐形.

如果滚动栏不占用任何空间,则什么都不做.

# 使用量

```js
import {RemoveScrollBar} from 'react-remove-scroll-bar';

<RemoveScrollBar /> -> no scroll bar
```

### 右边框

防止内容跳出 **位置:已固定** 元素为 `right:0` 应当应用额外的类名. 它只会提供 _非零_ 是的,当它需要的时候, 保持正确的"差距".

```js
import {zeroRightClassName,fullWidthClassName, noScrollbarsClassName} from 'react-remove-scroll-bar';

// to set `right:0` on an element
<div className={zeroRightClassName} />

// to set `width:100%` on an element
<div className={fullWidthClassName} />

// to remove scrollbar from an element
<div className={noScrollbarsClassName} />

```

# 大小

压缩后500b(不包括tslib).

# 滚动- Locky

所有代码都是因为 [反应- 滚动- 锁定](https://github.com/theKashey/react-scroll-locky) 复设相.

# 条款

有一篇关于防止身体卷轴的中篇文章 [如何对抗卷轴](https://medium.com/@antonkorzunov/how-to-fight-the-body-scroll-2b00267b37ac)

# 许可证

麻省理工学院

## 常见问题

### react-remove-scroll-bar 是什么？

删除没有内容的正文卷轴 摇摆

### 如何安装 react-remove-scroll-bar？

在项目目录运行 npm install react-remove-scroll-bar，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（^16\.8\.0 \|\| ^17\.0\.0 \|\| ^18\.0\.0 \|\| ^19\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### react-remove-scroll-bar 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### react-remove-scroll-bar 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### react-remove-scroll-bar 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=10。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### react-remove-scroll-bar 可以商用吗？

react-remove-scroll-bar 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### react-remove-scroll-bar 的下载量有多少？

根据 npm 官方下载统计，react-remove-scroll-bar 在 2026/10/07 – 2026/11/05 这 30 天内被下载 302,852,838 次，日均约 10,095,095 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### react-remove-scroll-bar 还在维护吗？

最新版本 2\.3\.8 发布于 2024/12/15（1\.9 年前）；至今共发布 20 个版本，其中过去 12 个月发布了 0 个；首次发布于 2019/01/18。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

