0.1.2 • Published 4 years ago

youpin-ui v0.1.2

Weekly downloads
5
License
MIT
Repository
-
Last release
4 years ago

youpin-ui

安装

npm 安装

推荐使用 npm 的方式安装,它能更好地和 webpack 打包工具配合使用。

npm i youpin-ui -S

快速上手

本节将介绍如何在项目中使用组件库。

引入 YoupinUi

你可以引入整个 YoupinUi,或是根据需要仅引入部分组件。

完整引入

在 main.js 中写入以下内容:

import Vue from 'vue';
import YoupinUi from 'youpin-ui';
import 'youpin-ui/lib/theme/index.css';
import App from './App.vue';

Vue.use(YoupinUi);

new Vue({
  el: '#app',
  render: h => h(App)
});

注意:样式文件需要单独引入。

按需引入

借助 babel-plugin-component,我们可以只引入需要的组件,以达到减小项目体积的目的。

首先,安装 babel-plugin-component:

npm install babel-plugin-component -D

然后,将 .babelrc 修改为:

{
  "presets": [["es2015", { "modules": false }]],
  "plugins": [
    [
      "component",
      {
        "libraryName": "youpin-ui",
        "styleLibraryName": "theme"
      }
    ]
  ]
}

接下来,如果你只希望引入部分组件,比如 只需要引入fileList,那么需要在 main.js 中写入以下内容:

import Vue from 'vue';
import { fileList } from 'youpin-ui';
import App from './App.vue';

Vue.component(fileList.name, fileList);
/* 或写为
 * Vue.use(fileList)
 */

new Vue({
  el: '#app',
  render: h => h(App)
});
0.1.2

4 years ago

0.1.1

5 years ago

0.1.0

5 years ago