当前位置: 首页 > news >正文

Wot Design Uni:一个高颜值、轻量化的uni-app组件库,uni-app生态的新宠

一、介绍

图片

wot-design-uni组件库基于vue3+Typescript构建,参照wot design的设计规范进行开发,提供70+高质量组件,支持暗黑模式、国际化和自定义主题,旨在给开发者提供统一的UI交互,同时提高研发的开发效率。

特性:

🎯 多平台覆盖,支持 微信小程序、支付宝小程序、钉钉小程序、H5、APP 等.

🚀 70+ 个高质量组件,覆盖移动端主流场景.

💪 使用 Typescript 构建,提供良好的组件类型系统.

🌍 支持国际化,内置 6 种语言包.

📖 提供丰富的文档和组件示例.

🎨 支持修改 CSS 变量实现主题定制.

🍭 支持暗黑模式

二、安装及使用

Wot Design Uni提供了uni_modules和npm两种安装方式,按需选择。

使用uni_modules安装无需额外配置,即插即用,但是每次更新组件库需要处理代码差异(一般直接覆盖就可以)。

使用npm安装需要额外配置,更新组件库时无需处理代码差异。

2.1 安装

uni_modules安装:

在uni-app插件市场选择使用HBuildX导入,或者选择手动在src目录下创建uni_modules文件夹并将Wot Design Uni解压到uni_modules中,结构如下:

- uni_modules
- - - wot-design-uni

npm安装:

// npm
npm i wot-design-uni// yarn 
yarn add wot-design-uni// pnpm
pnpm add wot-design-uni

2.2 自动引入组件

配置easycom引入:
传统vue组件,需要安装、引用、注册,三个步骤后才能使用组件。easycom将其精简为一步。只要组件路径符合规范,就可以不用引用、注册,直接在页面中使用。

// pages.json
{"easycom": {"autoscan": true,"custom": {"^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue"}},"pages": [// ......]
}

基于vite配置引入:
可以通过@uni-helper/vite-plugin-uni-components实现组件的自动引入。

// npm
npm i @uni-helper/vite-plugin-uni-components -D// yarn
yarn add @uni-helper/vite-plugin-uni-components -D// pnpm
pnpm add @uni-helper/vite-plugin-uni-components -D

@uni-helper/vite-plugin-uni-components 0.0.8及之前版本vite.config.ts配置如下:

// vite.config.ts
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";import Components, { kebabCase } from '@uni-helper/vite-plugin-uni-components'export default defineConfig({plugins: [// make sure put it before `Uni()`Components({resolvers: [{type: 'component',resolve: (name: string) => {if (name.match(/^Wd[A-Z]/)) {const compName = kebabCase(name)return {name,from: `wot-design-uni/components/${compName}/${compName}.vue`,}}},}]}), uni()],
});

@uni-helper/vite-plugin-uni-components 0.0.9及以后版本vite.config.ts配置如下:

// vite.config.ts
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";import Components from '@uni-helper/vite-plugin-uni-components'
import { WotResolver } from '@uni-helper/vite-plugin-uni-components/resolvers'export default defineConfig({plugins: [// make sure put it before `Uni()`Components({resolvers: [WotResolver()]}), uni()],
});

2.3 使用

Wot Design Uni安装、配置完成之后,支持组件自动引入,故可以直接在SFC中使用,无需在页面内import,也不需要在components内声明,即可在任意页面使用。值得注意的是,uni-app平台不支持全局挂载组件,所以Message、Toast等组件仍需在SFC中显式使用,例如:

// 使用toast
<wd-toast></wd-toast>// 使用MessageBox
<wd-message-box></wd-message-box>

三、定制主题

3.1 自定义主题

Wot Design Uni 每1个组件基本都有自定义类名 custom-class,可以在组件根节点加入你页面上的类名,进行样式修改。

3.2 定制主题

每个组件提供了css 变量,可以参考config-provider组件的使用介绍来定制主题。

Wot 组件通过丰富的 CSS 变量 来组织样式,通过覆盖这些 CSS 变量,可以实现定制主题、动态切换主题等效果。

这些变量的默认值被定义在 page 节点上,如果要转 H5,默认值被定义在 :root 节点上。

:root,
page {--wot-color-success: red;--wot-color-warning: yellow;
}

通过 CSS 覆盖:你可以直接在代码中覆盖这些 CSS 变量,Button 组件的样式会随之发生改变。
/* 添加这段样式后,默认 Button 底色会变成绿色 */

:root,
page {--wot-button-normal-bg: green;
}

通过 ConfigProvider 覆盖:
ConfigProvider 组件提供了覆盖 CSS 变量的能力,你需要在根节点包裹一个 ConfigProvider 组件,并通过 theme-vars 属性来配置一些主题变量。

<wd-config-provider :theme-vars="themeVars"><div style="margin: 16px"><wd-button round block type="primary">提交</wd-button></div>
</wd-config-provider>
import { ref, reactive } from 'vue'export default {setup() {// themeVars 内的值会被转换成对应 CSS 变量// 比如 buttonPrimaryBg 会转换成 `--wot-button-primary-bg-color`const themeVars = reactive({buttonPrimaryBgColor: '#07c160',buttonPrimaryColor: '#07c160'})return {themeVars}}
}

按钮&弹框

在这里插入图片描述
在这里插入图片描述

Tabbar&Form表单

在这里插入图片描述
在这里插入图片描述

水印&锚点

在这里插入图片描述
在这里插入图片描述

图片裁剪&日历组件
在这里插入图片描述

在这里插入图片描述

做为uni-app生态的新宠,为跨平台开发注入了新的活力,也给我们带来了多样的选择。

Wot Design Uni颜值高,组件丰富,更新速度快,使用Wot Design Uni开发微信、支付宝等小程序是一个不错的选择。

文档地址:https://wot-design-uni.pages.dev/

github地址:https://github.com/Moonofweisheng/wot-design-uni

gitee地址:https://gitee.com/wot-design-uni/wot-design-uni

原文地址:原文地址


http://www.mrgr.cn/news/5163.html

相关文章:

  • 2025计算机毕设:50条小众好做的SSM题目推荐【计算机毕设选题推荐】
  • 数学建模之数据分析【七】:对Pandas DataFrame 进行切片
  • LCD 驱动
  • 《python语言程序设计》2018版第8章第2题检查子串, 使用str类的find方法检查一个字符串是否是另一个字符串的子串
  • 商业软件许可证介绍|简单原理探究
  • 6.MySQL的增删改查
  • QT中使用QAxObject类读取xlsx文件内容并显示在ui界面
  • 【K8s】Java项目部署时为什么要用k8s?
  • 身份证OCR-身份证OCR识别-身份证OCR文字识别-身份证识别--身份证图像识别-身份证信息识别接口
  • python实现链表
  • 设计模式-责任链模式
  • Python类的介绍
  • 实现Linux的高可用负载均衡
  • 【云原生】企业级WEB应用服务器TOMCAT
  • 在VS Code中使用Snippet Craft扩展提高编码效率
  • 论文阅读:MonoScene: Monocular 3D Semantic Scene Completion
  • vue生命周期函数
  • 探索提示工程 Prompt Engineering的奥妙
  • git常用操作合集
  • SparkContext与SparkSession区别