vue+element-ui implements the head navigation bar component

vue+element-ui implements the head navigation bar component

This article shares the specific code of vue+element-ui to implement the head navigation bar component for your reference. The specific content is as follows

Without further ado, here's a rendering:

This is a header navigation bar, the most common function on a website. Click the mouse to switch between different interfaces, and the style follows.
The first step is to download the element-ui framework

npm install element-ui

Import this UI framework globally in the main.js file

Then register the top component in the app.vue file

This is the head navigation bar implemented by vue and "hungry", take a look at the code:

<template>
  <div class="header">
    <div class="img">
      <img src="@/assets/image/index/logo.png" alt="">
    </div>
    <el-menu
      :default-active="this.$route.path"
      class="el-menu-demo"
      mode="horizontal"
      @select="handleSelect"
      router
      background-color="#fff"
      text-color="#333"
      active-text-color="#0084ff"
      style="flex:1"
    >
      <el-menu-item v-for="(item, i) in navList" :key="i" :index="item.name">
        <template slot="title">
          <span> {{ item.navItem }}</span>
        </template>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
    data() {
    return {
        navList:[
            {name:'/home', navItem:'Home'},
            {name:'/home/classRoom',navItem:'My Class'},
            {name:'/home/course',navItem:'My Course'},
            {name:'/home/exam',navItem:'Create an exam'},
            {name:'/home/practice',navItem:'Create a practice'},
        ]
                      
    }
  },
  methods: {
    handleSelect(key, keyPath) {
      }
  }
}
</script>

<style>
.el-menu-item{
  font-size: 18px !important;
}
.el-menu-item.is-active {
    color: #ea5b2c !important;
    font-size: 18px !important;
}
.el-menu--horizontal>.el-menu-item.is-active {
  border-bottom: 2px solid #ea5b2c !important;
}
</style>
<style lang="scss" scoped>
.header {
  display: flex;
  width: 100%;
  .img {
    background: #ffffff;
    border-bottom: solid 1px #e6e6e6;
    img {
      height:50px;
      padding:10px;
    }
  }
}
</style>

My ability is limited, so if there are any shortcomings in my writing, I hope the experts passing by can give me some pointers.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • ElementUI complex top and left navigation bar implementation example
  • Vue+Router+Element to implement a simple navigation bar
  • Element-ui sample code for implementing responsive navigation bar
  • Solution for highlighting the vue+element navigation bar
  • vue elementUI uses tabs to link with the navigation bar
  • Detailed explanation of how to use the navigation bar to jump to the route in element-ui
  • Implementation of default expansion function of navigation bar when using ElementUI in Vue
  • Vue2.0 elementUI makes breadcrumb navigation bar
  • ElementUI+named view to achieve complex top and left navigation bar

<<:  Detailed explanation of how to connect to MySQL database using Java in IntelliJ IDEA

>>:  Solution to the error problem of Vscode remotely connecting to Ubuntu

Recommend

Implementation of adding remark information to mysql

Preface Some people have asked me some MySQL note...

jQuery realizes the full function of shopping cart

This article shares the specific code of jQuery t...

CSS3 creates 3D cube loading effects

Brief Description This is a CSS3 cool 3D cube pre...

Use a few interview questions to look at the JavaScript execution mechanism

Table of contents Previous words Synchronous and ...

Docker Basic Tutorial: Detailed Explanation of Dockerfile Syntax

Preface Dockerfile is a script interpreted by the...

vue+el-upload realizes dynamic upload of multiple files

vue+el-upload multiple files dynamic upload, for ...

How to install elasticsearch and kibana in docker

Elasticsearch is very popular now, and many compa...

Element UI table realizes drop-down filtering function

This article example shares the specific code for...

Zabbix monitors the process of Linux system services

Zabbix automatically discovers rules to monitor s...

What is a MySQL index? Ask if you don't understand

Table of contents Overview From Binary Tree to B+...

Eclipse configures Tomcat and Tomcat has invalid port solution

Table of contents 1. Eclipse configures Tomcat 2....

Sample code for implementing follow ads with JavaScript

Floating ads are a very common form of advertisin...

How to design the homepage of Tudou.com

<br />I have been working in front-end for s...