Skip to content

华玥组件库

TIP

针对移动端项目,uniapp+vue3,需要使用到 uview-plus 组件库

温馨提示

node(推荐) >= 16.14.0

下载scss(没有的话需要安装)

shell
$ npm install sass -D
shell
$ pnpm install sass -D
shell
$ cnpm install sass -D
shell
$ yarn install sass -D

下载dayjs(没有的话需要安装)

shell
$ npm install dayjs
shell
$ pnpm install dayjs
shell
$ cnpm install dayjs
shell
$ yarn install dayjs

安装组件

shell
$ npm install hy-app
shell
$ pnpm install hy-app
shell
$ cnpm install hy-app
shell
$ yarn install hy-app

按需引入组件

html
<yk-input></yk-input>
javascript
import { ykInput } from 'hy-app'

如何全局引入组件

1. 如果你只想在h5使用,你可以这么引入

温馨提示

这种会增加主包体积,不推荐微信小程序使用

./src/main.ts
ts
import { createSSRApp } from "vue";
import App from "./App.vue";
import { install } from "hy-app";

export function createApp() {
    const app = createSSRApp(App);
    app.use(install);
    return {
        app
    };
}
2. 如果你想按需加载。你可以这个全局定义
html
<!-- 然后在所需页面直接使用 -->
<hy-input></hy-input>

在pages.json文件引入全局组件库

./src/pages.json
json
{
  "easycom": {
    "custom": {
      "^hy-(.*)": "hy-app/components/hy-$1/hy-$1.vue"
    }
  }
}