# 快速上手
开始之前
使用 FirstUI UNI版前,请确保你已经学习并熟练使用过 uni-app (opens new window) 。
# 安装
# 方式一 :通过 npm 安装
使通过 npm 安装,需要先通过 vue-cli 创建 uni-app 项目,详见 。
// # Using npm
npm install firstui-uni
1
2
2
注意
通过 npm 安装,建议使用easycom组件规范,在 pages.json
中 添加配置:
"easycom": {
"autoscan": true,
"custom": {
"fui-(.*)": "firstui-uni/firstui/fui-$1/fui-$1.vue"
}
}
1
2
3
4
5
6
2
3
4
5
6
# 方式二 :通过下载代码
通过 GitHub 或者 FirstUI官网(VIP) 下载 First UI 的代码,然后 将 components/firstui/ 目录拷贝到自己的项目中。
// # GitHub
git clone https://github.com/FirstUI/FirstUI.git
1
2
2
# 方式三 :选择需要的模块引入
下载 First UI 的代码,在 components/firstui/ 目录下找到需要的组件拷贝到自己的项目中。
# 如何使用
按照以下的方式使用组件,以 Button
为例,其它组件在对应的文档页查看。
第一种:在页面中引用、注册(npm安装建议使用easycom组件规范)
import fuiButton from "@/components/firstui/fui-button/fui-button.vue"
export default {
components:{
fuiButton
}
}
1
2
3
4
5
6
2
3
4
5
6
第二种:easycom组件规范
传统vue组件,需要安装、引用、注册,三个步骤后才能使用组件。easycom将其精简为一步,如果不了解easycom,可先查看 官网文档 。
在 pages.json
中 添加配置,确保路径引入正确:
// 下载安装时easycom配置
"easycom": {
"autoscan": true,
"custom": {
"fui-(.*)": "@/components/firstui/fui-$1/fui-$1.vue"
}
}
// 使用npm安装时easycom配置(配置完成后重新编译运行)
"easycom": {
"autoscan": true,
"custom": {
"fui-(.*)": "firstui-uni/firstui/fui-$1/fui-$1.vue"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 使用组件
引入组件后,可以在 页面 中直接使用组件
<fui-button text="默认按钮"></fui-button>
1