#Today, I built a web page with [ElementUI]. I found it really good after using it up##

Article catalog

preface

ElementUI is a desktop component library based on Vue 2.0 for developers, designers and product managers.
It is a UI framework based on Vue, which develops many related components based on Vue to facilitate us to quickly develop pages.

1, Download of ElementUI

ElementUI can be downloaded on the official website:

Official website address: https://element.eleme.cn/#/zh-CN

      

When writing page code, we can directly refer to the component guide on the official website of elementui. When using VSCode, we need to import three packages, one is the index of elementui CSS style package, one is index js script package, and Vue's js package. I will give you these three packages in the next forum. The following is the process of guiding the package.

Note: the package must be guided in order!

①<link rel="stylesheet" href="../element-ui-2.13.0/lib/theme-chalk/index.css">

②<script src="../js/vue-v2.6.10.js"></script>

③<script src="../element-ui-2.13.0/lib/index.js"></script

2, Use of ElementUI

2.1 Layout

el-row
parameterexplaintypeOptional valueDefault value
gutterGrid spacingnumber-------0
typeThe default layout is flex, which is valid in modern browsersstring----------
justifyHorizontal arrangement under flex layoutstringstart/end/center...start
alignVertical arrangement under flex layoutstringtop/middle/bottomtop
tagCustom element labelsstring*div
el-col
parameterexplaintypeOptional valueDefault value
spanNumber of columns occupied by the gridnumber-------24
offsetNumber of spacing cells to the left of the gridnumber-------0
pushThe number of cells the grid moves to the rightnumber-------0
pullThe number of cells the grid moves to the leftnumber-------0
xs< 768px responsive grid number or grid attribute objectnumber/object--------------

Referring to the responsive design of Bootstrap, five response dimensions are preset: xs mobile phone, sm flat panel, md desktop display, lg large desktop display and xl Large desktop display.  

2.2 Container layout

Common labels:
< El container >: outer container. When the child element contains < El header > or < El footer >, all child elements will be arranged vertically up and down, otherwise they will be arranged horizontally left and right.

< El header >: top bar container.

< El aside >: sidebar container.

< El main >: main area container.

< El footer >: bottom bar container.

The above components adopt flex layout. Please determine whether the target browser is compatible before use. In addition, the child element of < El container > can only be the last four, and the parent element of the last four can only be < El container >

 

The following are common attributes of container, header, left side of aside and bottom of footer:

Container Attributes
parameterexplaintypeOptional valueDefault value
directionArrangement direction of child elementsstringhorizontal / verticalvertical when there is , El header , or , El footer , in the child element; horizontal otherwise

 

Header Attributes
parameterexplaintypeOptional valueDefault value
heightTop rail heightstring--------60p

 

Aside Attributes
parameterexplaintypeOptional valueDefault value
widthSidebar widthstring--------300px

                     

Footer Attributes
parameterexplaintypeOptional valueDefault value
heightBottom rail heightstring--------60px

 

2.3 buttons

Here are some common buttons:

​
<el-row>
     <el-button>Default button</el-button>
     <el-button type="primary" disabled>Main button</el-button>
     <el-button type="success" size="mini">Success button</el-button>
     <el-button type="info">Information button</el-button>
     <el-button type="warning">Warning button</el-button>
     <el-button type="danger">Danger button</el-button>
   </el-row>

   <el-row>
     <el-button plain>Plain button</el-button>
     <el-button type="primary" plain>Main button</el-button>
     <el-button type="success" plain>Success button</el-button>
     <el-button type="info" plain>Information button</el-button>
     <el-button type="warning" plain>Warning button</el-button>
     <el-button type="danger" plain>Danger button</el-button>
   </el-row>

   <el-row>
     <el-button round>Fillet button</el-button>
     <el-button type="primary" round>Main button</el-button>
     <el-button type="success" round>Success button</el-button>
     <el-button type="info" round>Information button</el-button>
     <el-button type="warning" round>Warning button</el-button>
     <el-button type="danger" round>Danger button</el-button>
   </el-row>

​

Common button properties

Attributes
parameterexplaintypeOptional valueDefault value
sizesizestringmedium / small / mini--------
typetypestringprimary / success / warning / danger / info / text--------
plainIs it a simple buttonboolean-------false
roundFillet buttonboolean-------false
circleRound buttonboolean-------false
loadingLoading statusboolean-------false
disabledDisable statusboolean-------false
iconIcon class namestring--------------
autofocusDefault aggregationboolean-------false
native-typeNative type attributestringbutton / submit / resetbutton

         

2.4 navigation menu

The following is the navigation menu I copied and the background system home page written by the container. You can use it directly

     

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Student management system</title>
    <link rel="stylesheet" href="../element-ui-2.13.0/lib/theme-chalk/index.css">
    <script src="../js/vue-v2.6.10.js"></script>
    <script src="../element-ui-2.13.0/lib/index.js"></script>
    <style>
        .el-header, .el-footer {
          background-color: rgb(105,139,105);
          color: #333;
          text-align: center;
          line-height: 60px;
        }
        
        .el-aside {
          background-color: rgb(84,92,100);
          color: #333;
          text-align: center;
          line-height: 200px;
          height: 640px;
        }
        
        .el-main {
          background-color: #E9EEF3;
          color: #333;
          text-align: center;
          line-height: 160px;
        }
        
        body > .el-container {
          margin-bottom: 40px;
        }
        
        .el-container:nth-child(5) .el-aside,
        .el-container:nth-child(6) .el-aside {
          line-height: 260px;
        }
        
        .el-container:nth-child(7) .el-aside {
          line-height: 320px;
        }
      </style>
</head>
<body>
    <div id="app">
        <el-container>
            <el-header height="100px">
                <h1>Student management system</h1>
            </el-header>
            <el-container>
              <el-aside width="200px">
                <el-col :span="24">
                    <el-menu
                      default-active="2"
                      class="el-menu-vertical-demo"
                      @open="handleOpen"
                      @close="handleClose"
                      background-color="#545c64"
                      text-color="#fff"
                      active-text-color="#ffd04b">
                      <el-submenu index="1">
                        <template slot="title">
                          <i class="el-icon-location"></i>
                          <span>management function</span>
                        </template>
                        <el-menu-item-group>
                          <el-menu-item index="1-1">Student management</el-menu-item>
                          <el-menu-item index="1-2">Option 2</el-menu-item>
                        </el-menu-item-group>
                          <el-menu-item index="1-3">Option 3</el-menu-item>
                        </el-menu-item-group>

                      </el-submenu>
                      <el-menu-item index="2">
                        <i class="el-icon-menu"></i>
                        <span slot="title">Navigation II</span>
                      </el-menu-item>
                      <el-menu-item index="4">
                        <i class="el-icon-setting"></i>
                        <span slot="title">Navigation IV</span>
                      </el-menu-item>
                    </el-menu>
                  </el-col>
                </el-row>
              </el-aside>
              <el-main height="400px">
                 
              </el-main>
            </el-container>
          </el-container>
    </div>
</body>
<script>
    new Vue({
        el:"#app",
        data:{
            
        },
        methods:{
            handleOpen(key, keyPath) {
        console.log(key, keyPath);
        },
           handleClose(key, keyPath) {
        console.log(key, keyPath);
      }
        }
    })
</script>
</html>

Page effect

 

Common properties

Menu Attribute
parameterexplaintypeOptional valueDefault value
modepatternstringhorizontal / verticalvertical
collapseWhether to collapse the menu horizontally (only available when mode is vertical)boolean-------false
background-colorBackground color of menu (only hex format is supported)string-------#ffffff
text-colorText color of the menu (only hex format is supported)string-------#303133
active-text-colorText color of the currently active menu (only hex format is supported)string-------#409EFF
defalut-activeindex of the currently active menustring---------------
default-openedsThe index array of the currently open sub menuArray---------------
unique-openedKeep only one submenu expandedboolean-------false
menu-triggerTrigger mode of submenu opening (only valid when mode is horizontal)stringhover / clickhover
routerWhether to use Vue router mode. If this mode is enabled, index will be used as the path for route jump when navigation is activatedboolean-------false
collapse-transitionTurn on collapse animationboolean-------true

Method

Menu Methods
Method nameexplainparameter
openExpand the specified sub menuIndex: the index of the sub menu to be opened
closeCollapse the specified sub menuIndex: the index of the sub menu to be stowed

Events

Menu Events
Event nameexplainCallback Arguments
selectMenu activation callbackIndex: select the index of the menu item, indexpath: select the index path of the menu item
openCallback for sub menu expansion
Index: index of open sub menu, indexPath: index path of open sub menu
closeSub menu retracted callbackIndex: index of the stowed sub menu, indexPath: index path of the stowed sub menu
                                                               

 

Keywords: Javascript html

Added by deansatch on Sat, 22 Jan 2022 16:27:28 +0200