@arco-design/mobile-react

中文文档
2.39.1发布于 2026/06/03ISCESM + CJS近 30 天下载 6263

Follow the steps below to quickly get started using the component library.

原始使用文档
文档目录14 节
  1. Installation
  2. Project Dependencies
  3. Self-adaptation
  4. Import with CDN
  5. Full import
  6. Partial import (Recommended)
  7. Import components on demand
  8. Import icons on demand
  9. Partial import(Vite)
  10. Import components on demand
  11. Import icons on demand
  12. Partial import (manual)
  13. Theme variable customization & dynamic switching
  14. Using components on PC

Quick Start

Follow the steps below to quickly get started using the component library.

========

Installation

npm install @arco-design/mobile-react -S

Project Dependencies

"peerDependencies": {
    "react": ">=16.9.0",
    "react-dom": ">=16.9.0",
    "react-transition-group": ">=4.3.0"
}

Self-adaptation

The style uses rem for self-adaptation (@base-font-size: 50px). Please make sure that the project has introduced flexible.js or other tool functions that can set the basic font size for html according to the screen size. You can also import flexible.js provided in this component library:

import setRootPixel from '@arco-design/mobile-react/tools/flexible';

setRootPixel();

If the baseFontSize is different, you can change the incoming parameters and change the @base-font-size variable:

// js
/**
 * @param baseFontSize Baseline fontSize of 1rem, default 50
 * @param sketchWidth Width of UI draft, default 375
 * @param maxFontSize Maximum fontSize limit, default 64
 * @return {() => void} removeRootPixel Cancel the baseFontSize setting and remove the resize listener
 */
setRootPixel(37.5);

// less options
lessOptions: {
    javascriptEnabled: true,
    modifyVars: {
        '@base-font-size': 37.5,
    }
}

Import with CDN

You can import CDN resources through the <script> tag. Note that you need to import the CDN resources of peerDependencies first.

React & ReactDOM: Click here

React Transition Group: Click here

<link ref="stylesheet" href="https://unpkg.com/@arco-design/[email protected]/dist/style.min.css">
<script src="https://unpkg.com/@arco-design/[email protected]/dist/index.min.js"></script>

Full import

Note that style files need to be imported manually.

import Arco from '@arco-design/mobile-react';
import '@arco-design/mobile-react/esm/style';

It is recommended to use babel-plugin-import to import. (Click here to get more flexible configuration of this plugin):

npm install babel-plugin-import -D

Import components on demand

.babelrc.js:

plugins: [
    ["import", {
        "libraryName": "@arco-design/mobile-react",
        "libraryDirectory": "esm", // In SSR environment, you need to use `cjs` here
        "style": (path) => `${path}/style`,
    }]
]

Import icons on demand

.babelrc.js:

plugins: [
    ["import", {
        "libraryName": "@arco-design/mobile-react/esm/icon", // In SSR environment, you need to replace `esm` with `cjs`
        "libraryDirectory": "",
        "camel2DashComponentName": false,
    }]
]

If both component and Icon need to be imported on demand, you need to add a different name value to the third parameter.

plugins: [
    ["import", {
        "libraryName": "@arco-design/mobile-react",
        "libraryDirectory": "esm", // In SSR environment, you need to use `cjs` here
        "style": (path) => `${path}/style`
    }, "@arco-design/mobile-react"],
    ["import", {
        "libraryName": "@arco-design/mobile-react/esm/icon", // In SSR environment, you need to replace `esm` with `cjs`
        "libraryDirectory": "",
        "camel2DashComponentName": false
    }, "@arco-design/mobile-react/esm/icon"]
]

Then you only need to write one line when importing, and it will be loaded on demand instead of completely imported when packaging:

import { Button as ArcoButton } from '@arco-design/mobile-react';

import { IconAsk, IconBack } from '@arco-design/mobile-react/esm/icon';

Partial import(Vite)

It is recommended to use vite-plugin-importer to import(Click here to know more from this plugin):

npm install vite-plugin-importer -D

Import components on demand

vite.config.ts :

import usePluginImport from 'vite-plugin-importer'

export default defineConfig({
    plugins: [
        usePluginImport({
            libraryName: "@arco-design/mobile-react",
            libraryDirectory: "esm",
            style: (path) => `${path}/style`,
        })
    ]
})

Import icons on demand

vite.config.ts :

import usePluginImport from 'vite-plugin-importer'

export default defineConfig({
    plugins: [
        usePluginImport({
            libraryName: "@arco-design/mobile-react/esm/icon",
            libraryDirectory: "",
            camel2DashComponentName: false,
        })
    ]
})

If both component and Icon need to be imported on demand, you just declare all and do not need any change.

vite.config.ts :

import usePluginImport from 'vite-plugin-importer'

export default defineConfig({
    plugins: [
        usePluginImport({
            libraryName: "@arco-design/mobile-react",
            libraryDirectory: "esm",
            style: (path) => `${path}/style`,
        }),
        usePluginImport({
            libraryName: "@arco-design/mobile-react/esm/icon",
            libraryDirectory: "",
            camel2DashComponentName: false,
        })
    ]
})

Partial import (manual)

If you don't use babel-plugin-import, you need to import js and css files manually. The following example has the same effect as the import statement above:

import ArcoButton from '@arco-design/mobile-react/esm/button';
import '@arco-design/mobile-react/esm/button/style';

import IconAsk from '@arco-design/mobile-react/esm/icon/IconAsk';

Theme variable customization & dynamic switching

This component library uses less and css variables for theme customization. The css variable is mainly used for dynamic theme switching at runtime, and is disabled by default. If there is a need for dynamic theme switching, you can configure less options to enable the css variable:

lessOptions: {
    javascriptEnabled: true,
    modifyVars: {
        '@use-css-vars': 1, // Enable css variables
    }
},

Note that after configuring and enabling css variables, if there is less variable substitution, you need to replace the css variables at the same time:

// less options
lessOptions: {
    javascriptEnabled: true,
    modifyVars: {
        '@base-font-size': 37.5,
        '@primary-color': 'red',
    }
}

// css
:root {
    --base-font-size: 37.5;
    --primary-color: red;
}

Using components on PC

Only touch-related events are monitored and processed in the component. If you need to use the component on the PC side, you can import touch2mouse.js provided by this component library to be compatible with mouse event processing (Note: After importing this file, the following mouse events will be blocked: mousedown, mouseenter, mouseleave, mousemove, mouseout, mouseover and mouseup, and the page content cannot be selected):

import '@arco-design/mobile-react/tools/touch2mouse';

版本与发布记录

@arco-design/mobile-react 共发布 77 个版本,首次发布于 2022/07/07;过去 12 个月发布了 4 个版本。

版本发布日期距今
2.39.1latest2026/06/035 个月前
2.39.02026/01/219 个月前
2.38.42025/12/1010 个月前
2.38.32025/12/0511 个月前
2.38.22025/09/221.1 年前
2.38.12025/09/151.1 年前

其他发布通道:canary → 2.19.2-ee92494.5。

关于 @arco-design/mobile-react 的常见问题

@arco-design/mobile-react 是什么?

Follow the steps below to quickly get started using the component library.

如何安装 @arco-design/mobile-react?

在项目目录运行 npm install @arco-design/mobile-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.9.0)、react-dom(>=16.9.0)、react-transition-group(>=4.3.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@arco-design/mobile-react 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/arco-design__mobile-react 是否存在。

@arco-design/mobile-react 支持 ESM 还是 CommonJS?

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

@arco-design/mobile-react 可以商用吗?

@arco-design/mobile-react 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@arco-design/mobile-react 的下载量有多少?

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

@arco-design/mobile-react 还在维护吗?

最新版本 2.39.1 发布于 2026/06/03(5 个月前);至今共发布 77 个版本,其中过去 12 个月发布了 4 个;首次发布于 2022/07/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。