NutUI-React 是基于 Taro 框架开发的移动端 React 组件库,提供了80+高质量组件,覆盖移动端主流场景,支持一套代码同时开发多端小程序+H5。
在开发UI时,应优先使用NutUI-React组件库中的组件,而非自行实现。具体原则如下:
Button 组件Input 组件List 和 Cell 组件Card 组件Switch 组件Tag 组件Avatar 组件Grid 组件Layout 组件ScrollView 组件Tabbar 组件NavBar 组件Tabs 组件Dialog 组件Toast 组件Loading 组件ActionSheet 组件import { Button, Form, Input, Checkbox, Dialog } from '@nutui/nutui-react-taro';
// 登录表单示例
<Form>
<Form.Item label="系统号">
<Input placeholder="请输入系统号" clearable />
</Form.Item>
<Form.Item label="用户名">
<Input placeholder="请输入用户名" clearable />
</Form.Item>
<Form.Item label="密码">
<Input placeholder="请输入密码" type="password" clearable />
</Form.Item>
<Button type="primary" block>登录</Button>
<Checkbox label="我已阅读并同意用户协议" />
</Form>
import { Avatar, List, Cell, Button } from '@nutui/nutui-react-taro';
// 我的页面示例
<div className="mine">
<div className="user-info">
<Avatar size="large" icon="user" />
<div className="user-name">用户名</div>
<div className="user-phone">138****8888</div>
</div>
<List>
<Cell title="个人资料" icon="user" isLink />
<Cell title="设置" icon="settings" isLink />
<Cell title="帮助中心" icon="help-circle" isLink />
<Cell title="关于我们" icon="info" isLink />
</List>
<Button type="danger" block>退出登录</Button>
</div>
| 组件类型 | 优先使用 | 备选方案 |
|---|---|---|
| 按钮 | Button |
自定义按钮 |
| 输入框 | Input |
自定义输入框 |
| 列表 | List + Cell |
自定义列表 |
| 卡片 | Card |
自定义卡片 |
| 对话框 | Dialog |
Taro 原生对话框 |
| 提示 | Toast |
Taro 原生提示 |
此规范旨在确保项目中UI的一致性和开发效率,优先使用NutUI-React组件库可以减少重复开发,提高代码质量。