帝国模板之家为广大用户提供专业、一站式建站服务。

网页特效

网页特效栏目收集了最全最新的前端网页插件,包括最流行的jQuery,Bootstrap,Js,Css,Vue等主流特效插件。

当前位置:首页 > 资源 > 网页特效 > 正文

Vue3(vue-dock-menu)多级菜单导航组件

帝国模板之家 2020-12-28 网页特效 评论

描述:

一个可定制的多层菜单(下拉菜单)组件,与最新的Vue.js 3框架兼容。

使用方法

1. 导入dock菜单组件

import { DockMenu } from "vue-dock-menu";
import "vue-dock-menu/dist/vue-dock-menu.css";

2.将DockMenu组件添加到应用模板,并使用themeprop覆盖默认样式,如下所示:

<DockMenu
  :items="items"
  :on-selected="handleSelected"
  :theme="{
    primary: '#b2b2b2',
    secondary: '#e5e5e5',
    tertiary: '#008ecc',
    textColor: '#000',
    textHoverColor: '#fff',
  }"
/>

3.注册组件,然后将自己的菜单项插入DockMenu。

export default {
  name: "App",
  components: {
    DockMenu,
  },
  setup() {
    const handleSelected = () => {};
    return {
      handleSelected,
    };
  },
  data() {
    return {
      count: 0,
      items: [
        {
          name: "file",
          menu: [
            { name: "New File" },
            { name: "New Window" },
            { name: "Open File" },
            { isDivider: true },
            {
              name: "Preferences",
              menu: [
                { name: "Settings" },
                {
                  name: "Themes",
                  menu: [
                    {
                      name: "White",
                      menu: [{ name: "white 1" }, { name: "white 2" }],
                    },
                    {
                      name: "Black",
                    },
                  ],
                },
              ],
            },
            { name: "Open Workspace" },
            { isDivider: true },
            { name: "Save" },
            { name: "Save As..." },
            { isDivider: true },
            { name: "Close" },
            { name: "Exit" },
          ],
        },
        {
          name: "edit",
          menu: [
            { name: "Undo" },
            { name: "Redo" },
            { isDivider: true },
            { name: "Cut" },
            { name: "Copy" },
            { name: "Paste" },
            { isDivider: true },
            { name: "Find" },
            { name: "Replace" },
          ],
        },
        {
          name: "View",
          menu: [
            { name: "Explorer" },
            { name: "Search" },
            { name: "Run" },
            { isDivider: true },
            {
              name: "Apperance",
              menu: [{ name: "Full Screen" }, { name: "Zen Mode" }],
            },
          ],
        },
        {
          name: "Help",
          menu: [{ name: "About" }, { name: "Check for Updates" }],
        },
      ],
    };
  },
};

4. 组件所有默认配置项。

items: {
  type: Array as PropType<MenuItemModel[]>,
  default: [] as MenuItemModel[],
  required: true,
},
dock: {
  required: false,
  default: MenuBarDockPosition.TOP,
  type: String,
},
parent: {
  required: false,
  default: "",
  type: String,
},
theme: {
  required: true,
  type: Object as PropType<MenuTheme>,
},
isMobile: {
  type: Boolean,
  default: false,
},
nested: {
  type: Boolean,
  default: false,
},
onSelected: {
  required: true,
  type: Function as PropType<
    ({ name, path }: { name: string; path: string }) => void
  >,
},
initialHighlightIndex: {
  required: false,
  type: Number,
  default: -1,
},
这世上无忧无虑的人,反而相对寿命会长点。

已有 位小伙伴发表了看法

欢迎 发表评论

  • 匿名发表

关于

帝国cms模板

网页插件

帝国模板之家 | www.moyouyouw.cn

本站所有模板/文章除标明原创外,均来自网络转载,版权归原作者所有,如果有侵犯到您的权益,请联系站长删除,谢谢! 寻找帝国cms模板首选帝国模板之家,用心做站,上线至今广受好评,值得信赖!

  • 交流群1:帝国cms交流群1
  • 交流群2:帝国cms交流群2
在线QQ 给我留言