zoukankan      html  css  js  c++  java
  • 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>

    记录自己的采坑之路,需要时方便查找
  • 相关阅读:
    monkey测试===Monkey测试结果分析(系列三)转
    monkey测试===Monkey测试策略(系列二)转
    Java数据结构——二叉树
    Java排序算法——快速排序
    Java排序算法——归并排序
    Java递归算法——汉诺塔问题
    Java递归算法——二分查找
    Java递归算法——变位字
    Java递归算法——阶乘
    Java递归算法——三角数字
  • 原文地址:https://www.cnblogs.com/hahahakc/p/14392941.html
Copyright © 2011-2022 走看看