It’s time to start a Vue component library of your own!!!

Time:2021-1-13

Doran-ui

Based on Vue (2. X) a set of background UI framework, UI design is based on the UI design of element and iView

At present, there are all kinds of excellent Vue component libraries in the market. Have you ever thought about how to realize the bottom layer? For a mature component library, it is extremely painful to look at the source code of the component library because it has been iterated many times,Doran UI has few iterations, and comments are added to the source code where it is difficult to understand. The source code is simple and easy to read. It is a good thing for learning progress and understanding the underlying knowledge, which is worth reading and learning
githubAddress, welcome to start, in addition, do not understand or find bugs, you can mentionissuesI’ll get back in time if I see it

Note: because it has not been tested and promoted, the UI is only for learning.

The views directory is the demo of each component

git clone https://github.com/ximoThorn/Doran.git
cd Doran
npm i
npm run serve

on-linepreview

Global introduction

Generally in the webpack entry page main.js The configuration is as follows:

import  Vue  from  'vue'
import  DoranUi  from  'doran'
import  'doran/dist/ doran.css '// introduce CSS
import  App  from  './App.vue'

Vue.use(DoranUi)

new  Vue({
    render: h  =>  h(App),
}).$mount('#app')

On demand introduction

With plug-insbabel-plugin-importIt can load components on demand and reduce the volume of files. First, install and configure in the project root file. Babelrc

NPM install Babel plugin import -- save dev // install

In. Babelrc file


{
    "plugins": [["import", {
        "libraryName": "doran",
        "libraryDirectory": "dist/components"
    }]]
}

Then, by introducing components as needed, the volume can be reduced

<template>
    <div  id="app">
        <dr-button  type="error">Doran</dr-button>
        < Dr input placeholder = "please input" > < / DR input >
    </div>
</template>
<script>
import { Button, Input } from  'doran'
export  default {
    name: 'App',
    components: {
        DrButton: Button,
        DrInput: Input
    }
}
</script>

Note: you still need to import styles for on-demand references main.js Global introduction in

Version

1.x

Completed components

This work adoptsCC agreementReprint must indicate the author and the link of this article