Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能

摘要:
--会员管理系统您好,王家伟iv˃--˃˂--组管理--˃组管理˂--端口管理帐户管理广告管理第1页第2页第3页任务管理˂a菜单项

参考:

https://www.cnblogs.com/wjw1014/p/13925969.html

Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第1张

 Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第2张

 路由调用

Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第3张Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第4张
import Hello from '@/Home/Hello'


Vue.use(Router)

export default new Router({
  routes: [

    {
      path: "/2",
      name: "Hello",
      component: Hello,
      redirect: '/teacher',
    },


    {
      path: "/teacher",
      component: Hello,
      meta: {title: '页面'},
      redirect: '/teacher/onepage',
      children: [
        {
          path: "onepage",
          name: "one",
          meta: {title: '页面一'},
          component: () => import("../Home/page01.vue")
        },
        {
          path: "twopage",
          name: "two",
          meta: {title: '页面二'},
          component: () => import("../Home/page02.vue")
        },
        {
          path: "threepage",
          name: "three",
          meta: {title: '页面三'},
          component: () => import("../Home/page03.vue")
        },
      ]
    },



  ]


})
index.js

父组件

Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第5张Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第6张
<template>
  <div>
    <!-- <div class="dd">
      <h1 class="hh1">成员管理系统</h1>
      <a-dropdown>
        <a class="ant-dropdown-link">
          你好,王佳伟
          <a-icon type="down" />
        </a>
        <a-menu slot="overlay">
          <a-menu-item>
            <a>修改密码</a>
          </a-menu-item>
          <a-menu-item>
            <a>推出登录</a>
          </a-menu-item>
        </a-menu>
      </a-dropdown>
    </div> -->

    <Generalmenu></Generalmenu>
    <div class="main">
      <!-- <app-mianbao></app-mianbao> -->
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
import Generalmenu from "./Generalmenu";
// import appMianbao from "./miaobao";

export default {
  name: "HelloWorld",
  components: {
    Generalmenu,
    // appMianbao
  },
  props: {
    msg: String
  }
};
</script>

<style scoped>
.dd,
.hh1 {
  background-color: #007acc;
  font-size: 40px;
  color: #fff;
  text-align: center;
  line-height: 80px;
  position: absolute;
  top: 0;
  left: 0;
   100%;
  height: 80px;
  vertical-align: middle;
}
.side {
  position: absolute;
   250px;
  top: 80px;
  left: 0;
  bottom: 0;
}
.main {
  position: absolute;
  top: 80px;
  left: 250px;
  bottom: 0;
  right: 0;
  padding: 10px;
}
.ant-dropdown-trigger {
  position:absolute;
  font-size: 15px;
  color: #fff;
  right: 20px;
}
</style>
Home\Hello.vue

子组件

Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第7张Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第8张
<template>
  <div>
        <div style=" 256px">
          <a-layout-sider v-model="collapsed" :trigger="null" collapsible>
            <div class="logo" />
            <a-menu theme="dark" mode="inline" :default-selected-keys="['1']">
              <a-menu-item key="1">
                <a-icon type="user" />
                <!-- <span>群组管理</span> -->

                <span>群组管理</span>
              
              </a-menu-item>
              <a-menu-item key="2">
                <a-icon type="video-camera" />
                <!-- <span>端口管理</span> -->
                <span>端口管理</span>
            
              </a-menu-item>
              <a-menu-item key="3">
                <a-icon type="upload" />
                <span>账号管理</span>
              </a-menu-item>

            <a-sub-menu key="sub1">
              <span slot="title"><a-icon type="mail" /><span>广告管理</span></span>
              <a-menu-item key="5">
                <router-link to="/teacher/onepage">页面一</router-link>
             
              </a-menu-item>

              <a-menu-item key="6">
                <router-link to="/teacher/twopage">页面二</router-link>
              </a-menu-item>
              
            <a-menu-item key="7">
                <router-link to="/teacher/threepage">页面三</router-link>
              </a-menu-item>

            </a-sub-menu>

            <a-sub-menu key="sub2">
              <span slot="title"><a-icon type="appstore" /><span>任务管理</span></span>
              <a-menu-item key="9">
                
                <span @click="guanzhu">关注</span>
              </a-menu-item>
              <a-menu-item key="10">
                私信
              </a-menu-item>
            
            </a-sub-menu>
              <a-sub-menu key="sub3">
                <span slot="title"><a-icon type="appstore" /><span>使用工具</span></span>
                <a-menu-item key="11">
                  短链接生成
                </a-menu-item>
              </a-sub-menu>
            </a-menu>
          </a-layout-sider>
        </div>










  </div>
</template>

<script>
export default {
  data() {
    return {
      collapsed: false,
      sId:0
    };
  },

  methods: {
    toggleCollapsed() {
      this.collapsed = !this.collapsed;
    },
    guanzhu(){
      this.$router.push('/details02')
    }


},


};
</script>
<style scoped>

.main_left{
     150px;
    height: 100%;
    float:left;
    background:#c0c0c0;
    cursor:pointer;
}
</style>
Home\Generalmenu.vue

页面

Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第9张Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能第10张
<template>

  <div class="bao">


    <a-breadcrumb separator='>'>
      <a-breadcrumb-item v-for="(item,index) of $route.matched" :key="index" style="padding:5px">
        <router-link :to="item.path" style="font-size:18px">{{item.meta.title}}</router-link>
      </a-breadcrumb-item>
    </a-breadcrumb>
   
  </div>

</template>

<script>
export default {

    watch :{
        '$route':'init'
    },
    mounted(){
        console.log(this.$route)
    },
    methods:{
        init(){
            console.log(this.$route)
        }
    }
    
};
</script>

<style scoped>
.bao{
   background-color: #fff;
   padding: 5px 0px;
   margin-bottom: 20px;
   border:1px solid #dddddd;
   padding-left: 10px;
   border-radius: 10px;
}
</style>
Home\page01.vue

免责声明:文章转载自《Vue 使用 Antd 简单实现左侧菜单栏和面包屑功能》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇首次揭秘!扫福得福:支付宝春节集五福背后的技术分享rsync命令下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

vue 好用的轮播插件之一 vue-seamless-scroll

1.安装 cnpm i vue-seamless-scroll -S 2.组件调用importvueSeamlessfrom"vue-seamless-scroll"; (或者全局注册) 3.https://www.npmjs.com/package/vue-seamless-scrollhttps://chenxuan0000.github.io/vue...

vue 中的 .sync 修饰符 与 this.$emit('update:key', value)

vue 中 .sync 修饰符,是 2.3.0+ 版本新增的功能 在有些情况下,我们可能需要对一个 prop 进行“双向绑定”。不幸的是,真正的双向绑定会带来维护上的问题,因为子组件可以变更父组件,且在父组件和子组件两侧都没有明显的变更来源。 这也是为什么我们推荐以update:myPropName的模式触发事件取而代之。举个例子,在一个包含titlepr...

vue组件如何引入外部.js/.css/.scss文件

可在相应的单vue组件引入相应文件。 1、引入外部.js文件。   2、引入外部.css文件。     使用@import引入外部css,作用域是全局的,也可在相应的单vue组件引入,import并不是引入代码到<style></style>里面,而是发起新的请求获得样式资源,并且没有加scoped。     注:如果有样式时,应该...

Vue全家桶

一、简介 武林至尊,宝刀React,号令天下,莫敢不从,Vue不出,谁与争锋本文介绍Vue全家桶:Vue+Vue-router+Vuex+axios。 二、Vue Vue 是一套用于构建用户界面的渐进式框架,和React,都自称自己只关注视图层 1.引入Vue 开发环境: <script src="https://cdn.jsdelivr.net/n...

openlayers集成到vue开发

openlayer初步加载地图 vue项目搭好后,直接用node js安装ol, 安装好后可以看看安装的版本;我用的是5..2的版本 然后看官网相对应版本的文档,都是英文文档; 官方文档: http://openlayers.org/en/latest/apidoc/ 然后引入所需要的js; 先加载出地图: 效果图: 使用离线地图时,重点注意的...

在原生 html 中使用 vue,在浏览器中直接运行 .vue 文件,在 vue 中使用 leaflet

vue3-in-html 在html中使用vue3,不依赖nodejs和webpack,不依赖脚手架 demo源码 https://gitee.com/s0611163/vue3-in-html 功能 编写了几个简单的组件,使用了element-plus和vuex 在vue3组件中使用leaflet实现电子地图 特色 原生 html 开发,不依赖 n...