Home > Web Front-end > JS Tutorial > body text

The road to Vue activity creation project starts with design and navigation bar development

不言
Release: 2018-07-09 11:39:43
Original
1919 people have browsed it

This article mainly introduces the design of the Vue activity creation project and the development of the navigation bar. It has a certain reference value. Now I share it with you. Friends in need can refer to it.

Let’s get started directly Project, I skipped basic operations like introducing Element-ui here

Division of project components

Based on the analysis of the project, I created the following new components.
The road to Vue activity creation project starts with design and navigation bar development

vue-router routing design

After the component is created, let’s set the routing
src/router/index.js

import Vue from 'vue'
import Router from 'vue-router'
import Index from 'components/Index'
import Login from 'components/Login'
import Regular from 'components/activity/regular/Regular'
import Topic from 'components/activity/topic/Topic'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'index',
      component: Index
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/Topic',
      component: Topic
    },
    {
      path: '/regular',
      component: Regular
    }
  ]
})
Copy after login

Here What should be noted is that the path of my import is set.
Find the resolve in build/webpack.base.conf.js and set our components to the bits of our components.
In this way, the components will be represented when importing. 'src/components' path

  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      'vue$': 'vue/dist/vue.esm.js',
      '@': resolve('src'),
      'components': resolve('src/components'),
    }
  }
Copy after login

nav-menu navigation bar development

Because Muse-ui is used, the navigation bar is copied directly from the document. The code is not included here. How to use it The document is very clear.
Here we will talk about the part involving Vue syntax. The title requirement on the left side of the navigation bar at the top of the project changes with the routing change. There is a watch listener in Vue. We use watch to monitor $route. Change to achieve this effect

Nav.vue

export default {
  name: 'Nav',
  data () {
    return {
      nowRouter: this.$route.name
    }
  },
  watch: {
    $route (to, from) {
      this.nowRouter = this.$route.name
    }
  }
}
Copy after login

Set these and run the command in the consolenpm run devLet’s see the effect

The road to Vue activity creation project starts with design and navigation bar development

You can see that the prototype of the page has been built

The above is the entire content of this article. I hope it will be helpful to everyone's learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Simple use of Vue scaffolding

The above is the detailed content of The road to Vue activity creation project starts with design and navigation bar development. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!