vue+iview框架实现左侧动态菜单功能的示例


当前第2页 返回上一页

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

67

68

69

70

71

72

73

74

75

76

77

78

79

80

<template>

 <p class="leftNav">

 <Menu ref="side_menu" theme="dark" accordion v-for="(menuItem, menuIndex) in menuList" :key="menuIndex" :active-name="$route.name">

  

  <!-- 展开没有子菜单 -->

  <MenuItem v-if="!menuItem.children || menuItem.children.length==0" :key="menuIndex" :name="menuItem.to" :to="menuItem.to">

  <Icon :type="menuItem.icon" />

  <span>{{ menuItem.name }}</span>

  </MenuItem>

  

  <!-- 展开有子菜单 -->

  <Submenu v-else :name="menuIndex">

   <template slot="title">

    <Icon :type="menuItem.icon" />

    <span>{{menuItem.name}}</span>

   </template>

   <MenuItem v-for="(item, index) in menuItem.children" :key="index" :name="item.to" :to="item.to">{{item.name}}</MenuItem>

  </Submenu>

 </Menu>

 </p>

    

</template>

<script>

export default {

 data() {

 return {

  menuList: [

  {

   name: "首页",

   to: "home",

   icon: "ios-archive-outline"

  },

  {

   name: "关于",

   to: "about",

   icon: "ios-create-outline"

  },

  {

   name: "菜单分类1",

   icon: "md-person",

   children: [

   {

    name: "用户",

    to: "user"

   }

   ]

  },

  {

   name: "菜单分类2",

   icon: "ios-copy",

   children: [

   {

    name: "测试",

    to: "test"

   }

   ]

  }

  ]

 };

 },

 created() {

 // 数据我先写静态的,可在初始化的时候通过请求,将数据指向menuList。

 // ajax成功回调后 this.menuList = response.data;

 // 别忘记更新菜单

 // this.$nextTick(() => {

 // this.$refs.side_menu.updateOpened()

 // this.$refs.side_menu.updateActiveName()

 //});

 }

};

</script>

<style lang="scss" scoped>

/deep/

 .ivu-menu-dark.ivu-menu-vertical

 .ivu-menu-item-active:not(.ivu-menu-submenu) {

 border-right: none;

 color: #fff;

 background: #2d8cf0 !important;

}

</style>

效果图:

相关学习推荐:编程视频

以上就是vue+iview框架实现左侧动态菜单功能的示例的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

vue和react中dom的区别

vue中如何分离css

vue项目全局使用axios的方法介绍

vue文件怎么打开

.vue文件可以写注释吗

vue.怎么绑定属性

eclipse支持vue

bootstrap与vue区别

怎么运行vue.js

vue项目通过import引入外部css报错怎么办

更多相关阅读请进入《vue》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...