2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!--
 * @Description: 导航菜单
 * @Author: 王旭
 * @Date: 2022-03-03 17:18:01
 * @LastEditTime: 2022-03-08 16:40:34
 * @LastEditors: 王旭
-->
<template>
  <div class="">
    <el-menu :default-active="`${pathName}`" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose"
      background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" router>
      <el-menu-item index="/gisServerList">
        <i class="el-icon-s-order"></i>
        <span slot="title">发布数据列表</span>
      </el-menu-item>
      <el-menu-item index="/journal">
        <i class="el-icon-menu"></i>
        <span slot="title">日志查看</span>
      </el-menu-item>
      <!-- <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>导航一</span>
        </template>
      </el-submenu> -->
    </el-menu>
  </div>
</template>
 
<script>
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      pathName: "",
    };
  },
  watch: {
    // 监听,当路由发生变化的时候执行
    $route(to, from) {
      this.pathName = to.path;
    },
  },
  //方法集合
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
  created() {
    //当前路由高亮
    this.pathName = this.$route.path;
  },
};
</script>
<style lang="less" scoped>
//@import url(); 引入公共css类
.el-menu {
  width: 100%;
}
</style>