Skip to content

安装

推荐使用 TypeScript 以获得更好的开发体验。

安装方法

  1. 本库依赖于以下库,需要安装这些库才能运行:
shell
npm i -S @imengyu/imengyu-utils @swjs/chinese-holidays async-validator tslib

因为UniApp不支持vite打包为库的模式,所以我没有将组件打包成npm包,而是直接将组件代码复制到项目中,所以目前只支持源码安装。

  1. 在Git仓库下载源代码,可以选择最新或者是 Release 中的版本。
  2. 复制 components 文件夹至你的项目中。
  3. 按需引用组件。

注:不支持easycom,因为它强制我将项目结构必须扁平化分成一个个文件夹,非常不便于开发和维护。而且通过 easycom 导入会失去组件TS提示。

使用

  1. 可在 App.vue 中为设置主题、全局配置(可选):
vue
<script setup lang="ts">
import { configTheme } from './components/theme/ThemeDefine';

//修改默认主题颜色
configTheme((theme) => {
  theme.colorConfigs.default.primary = '#ff8719';
  theme.colorConfigs.pressed.primary = '#b86212';
  return theme;
});
</script>
  1. 导入你需要的组件,然后在页面中使用:
vue
<template>
  <Button>默认按钮</Button>
</template>

<script setup lang="ts">
import Button from '@/components/Button.vue'
</script>