前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >cssjshtml vue.js 路由跳转,导航制作

cssjshtml vue.js 路由跳转,导航制作

作者头像
葫芦
发布2019-04-17 15:29:19
3K0
发布2019-04-17 15:29:19
举报
文章被收录于专栏:葫芦

main.js

代码语言:javascript
复制
import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue'
import Home from './components/Home'
import Menu from './components/Menu'
import Admin from './components/Admin'
import About from './components/about/About'
import Login from './components/Login'
import Register from './components/Register'


Vue.use(VueRouter)

const routes=[
  {path:'/',component:Home},
  {path:'/menu',component:Menu},
  {path:'/admin',component:Admin},
  {path:'/about',component:About},
  {path:'/login',component:Login},
  {path:'/register',component:Register}
]
const router=new VueRouter({
  routes,
  mode:'history'

})


new Vue({
  el: '#app',
  router,
  render: h => h(App)
})

App.vue

代码语言:javascript
复制
<template>
  <div id="app">
    <div class="container">
      <app-header></app-header>
    </div>
    <div class="container">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
  import Header from './components/Header'

  export default {
    components: {
      "app-header": Header,
    }
  }
</script>
<style>
</style>

Header.vue

代码语言:javascript
复制
<template>
  <header>
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      <a class="py-2" href="#">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
             stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
             class="d-block mx-auto">
          <circle cx="12" cy="12" r="10"></circle>
          <line x1="14.31" y1="8" x2="20.05" y2="17.94"></line>
          <line x1="9.69" y1="8" x2="21.17" y2="8"></line>
          <line x1="7.38" y1="12" x2="13.12" y2="2.06"></line>
          <line x1="9.69" y1="16" x2="3.95" y2="6.06"></line>
          <line x1="14.31" y1="16" x2="2.83" y2="16"></line>
          <line x1="16.62" y1="12" x2="10.88" y2="21.94"></line>
        </svg>
      </a>
      <router-link to="/" class="navbar-brand">Pizza点餐系统</router-link>
      <ul class="navbar-nav">
        <li><router-link to="/" class="nav-link">主页</router-link></li>
        <li><router-link to="menu" class="nav-link">菜单</router-link></li>
        <li><router-link to="admin" class="nav-link">管理</router-link></li>
        <li><router-link to="about" class="nav-link">关于我们</router-link></li>
      </ul>
      <ul class="navbar-nav ml-auto">
        <li><router-link to="login" class="nav-link">登录</router-link></li>
        <li><router-link to="register" class="nav-link">注册</router-link></li>


      </ul>
    </nav>

  </header>
</template>

<script>
  export default {
    name: "Header"
  }
</script>

<style scoped>

</style>

Login.vue

代码语言:javascript
复制
<template>
      <h1>Login</h1>

</template>

<script>
    export default {
        name: "Login"
    }
</script>

<style scoped>

</style>

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/01/09 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • main.js
  • App.vue
  • Header.vue
  • Login.vue
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档