• Ant-Design-Vue递归菜单的问题


    <template>
      <div style=" 256px">
        <a-menu
          :default-selected-keys="['1']"
          :default-open-keys="['2']"
          mode="inline"
          theme="dark"
          :inline-collapsed="collapsed"
        >
          <template v-for="item in list">
            <a-menu-item v-if="!item.children" :key="item.key">
              <a-icon type="pie-chart" />
              <span>{{ item.title }}</span>
            </a-menu-item>
            <sub-menu v-else :key="item.key" :menu-info="item" />
          </template>
        </a-menu>
      </div>
    </template>
    
    <script>
    import { Menu } from "ant-design-vue";
    const SubMenu = {
      template: `
          <a-sub-menu :key="menuInfo.key" v-bind="$props" v-on="$listeners">
            <span slot="title">
              <a-icon type="mail" /><span>{{ menuInfo.title }}</span>
            </span>
            <template v-for="item in menuInfo.children">
              <a-menu-item v-if="!item.children" :key="item.key">
                <a-icon type="pie-chart" />
                <span>{{ item.title }}</span>
              </a-menu-item>
              <sub-menu v-else :key="item.key" :menu-info="item" />
            </template>
          </a-sub-menu>
        `,
      name: "SubMenu",
      // must add isSubMenu: true
      isSubMenu: true,
      props: {
        ...Menu.SubMenu.props,
        // Cannot overlap with properties within Menu.SubMenu.props
        menuInfo: {
          type: Object,
          default: () => ({})
        }
      }
    };
    export default {
      components: {
        "sub-menu": SubMenu
      },
      data() {
        return {
          collapsed: false,
          list: [
            {
              key: "1",
              title: "Option 1"
            },
            {
              key: "2",
              title: "Navigation 2",
              children: [
                {
                  key: "2.1",
                  title: "Navigation 3",
                  children: [{ key: "2.1.1", title: "Option 2.1.1" }]
                }
              ]
            }
          ]
        };
      },
      methods: {}
    };
    </script>

    记录自己的采坑之路,需要时方便查找
  • 相关阅读:
    $(window).scrollTop()与$(dom).offset().top
    组织结构图
    杀人游戏
    猜数字游戏
    变量
    2018 -11-23 快捷键
    iOS开发—c语言 ATM取款机(全)2018-11-15
    iOS开发—c语言 ATM取款机(一)
    ios开发学习c语言第一天 2018-11-13
    iOS 面试题
  • 原文地址:https://www.cnblogs.com/hahahakc/p/14392941.html
Copyright © 2020-2023  润新知