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

Vue uses Canvas to generate random sized and non-overlapping circles

Table of contents Canvas related documents Effect...

10 SQL statement optimization techniques to improve MYSQL query efficiency

The execution efficiency of MySQL database has a ...

Experience of redesigning the homepage of TOM.COM

<br />Without any warning, I saw news on cnB...

Attributes and usage of ins and del tags

ins and del were introduced in HTML 4.0 to help au...

How to configure nginx+php+mysql in docker

First, understand a method: Entering a Docker con...

Detailed explanation of setting resource cache in nginx

I have always wanted to learn about caching. Afte...

The difference between GB2312, GBK and UTF-8 in web page encoding

First of all, we need to understand that GB2312, ...

Tips for viewing History records and adding timestamps in Linux

Tips for viewing History records and adding times...

How to modify the default submission method of the form

The default submission method of html is get inste...

Implementation of CSS Fantastic Border Animation Effect

Today I was browsing the blog site - shoptalkshow...

Detailed explanation of incompatible changes of components in vue3

Table of contents Functional Components How to wr...

Database index knowledge points summary

Table of contents First Look Index The concept of...

HTML Tutorial: DOCTYPE Abbreviation

When writing HTML code, the first line should be ...