UI使用篇
snail-uni 最终选择wot-design-uni作为默认UI库,开发者可以根据需求选择其他UI库,本篇将介绍wot-design-uni在过程中遇到的问题和其他UI库的替换方法。
wot-design-uni:一个基于Vue3+TS开发的uni-app组件库,提供70+高质量组件,支持暗黑模式、国际化和自定义主题
注意
截止2024-07-30 之前, Wot-design-uni目前支持 微信小程序、支付宝小程序、钉钉小程序、H5、APP 等平台! 如果需要适配其他平台请卸载wot-design-uni,并安装使用其他UI库。
组件问题
关于Wot-design-uni组件库的使用问题请移步至常见问题
UI库替换
snail-uni 脚手架支持选择不用版本的ui库,如果你已经安装使用了wot-design-uni,不想重新构建的情况下请先卸载wot-design-uni,然后按照以下步骤安装其他UI库(其他UI相同操作,不再赘述)
- 以
wot-design-uni为例
1.卸载wot-design-uni
sh
$ pnpm remove wot-design-unish
$ npm uninstall wot-design-unish
$ yarn remove wot-design-unish
$ bun remove wot-design-uni2.删除配置文件
在src/pages.config.ts 文件删除相关配置:
ts
easycom: {
autoscan: true,
custom: {
'^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
},
},3.安装其他UI库
注: 详细文档请查阅官方文档
- uni-ui文档:
uni-app官方维护的UI组件库 - uv-ui文档:
uv-ui破釜沉舟之兼容vue3+2、nvue、app、h5、小程序等多端基于uni-app和uView2.x的生态框架,支持单独导入,开箱即用,利剑出击 - uview-plus文档:
uview-plus是全面兼容nvue的uni-app生态框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水 - tuniao-ui-uniapp-v3文档:
TuniaoUI vue3 uniapp是一款基于uniapp、vue3、Typescript进行开发的UI组件库
sh
pnpm add @dcloudio/uni-ui
# or npm
# npm install @dcloudio/uni-ui
# or yarn
# yarn add @dcloudio/uni-uish
pnpm add uv-ui
# or npm
# npm install @climblee/uv-ui
# or yarn
# yarn add @climblee/uv-uish
pnpm add uview-plus
# or npm
# npm install uview-plus
# or yarn
# yarn add uview-plussh
pnpm add @tuniao/tnui-vue3-uniapp @tuniao/tn-icon @tuniao/tn-style
# or npm
# npm install @tuniao/tnui-vue3-uniapp @tuniao/tn-icon @tuniao/tn-style
# or yarn
# yarn add @tuniao/tnui-vue3-uniapp @tuniao/tn-icon @tuniao/tn-style4.配置其他UI库
- 在
src/pages.config.ts文件添加相关配置:
ts
easycom: {
autoscan: true,
custom: {
"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
}
},ts
easycom: {
autoscan: true,
custom: {
'^uv-(.*)': '@climblee/uv-ui/components/uv-$1/uv-$1.vue',
},
},ts
easycom: {
autoscan: true,
custom: {
"^u--(.*)": "uview-plus/components/u-$1/u-$1.vue",
"^up-(.*)": "uview-plus/components/u-$1/u-$1.vue",
"^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue"
}
}ts
{
easycom: {
custom: {
"^tn-(.*)-(item|group)$": "@tuniao/tnui-vue3-uniapp/components/$1/src/$1-$2.vue",
"^tn-(.*)": "@tuniao/tnui-vue3-uniapp/components/$1/src/$1.vue"
}
},
}- 在
src/tsconfig.json文件添加相关配置:
json
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"@types/wechat-miniprogram",
"@uni-helper/uni-ui-types",
]
}
}json
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"@types/wechat-miniprogram",
"@ttou/uv-typings/shim",
"@ttou/uv-typings/v2",
]
}
}json
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"@types/wechat-miniprogram",
"uview-plus/types/index.d.ts",
]
}
}json
{
"compilerOptions": {
"types": [
"@dcloudio/types",
"@types/wechat-miniprogram",
"@tuniao/tnui-vue3-uniapp/types/index.d.ts",
"@tuniao/tn-icon/types/index.d.ts",
]
}
}