当前位置: 首页 > wzjs >正文

mui 网站开发wordpress简约博客

mui 网站开发,wordpress简约博客,colorway wordpress,网站建设带有注册账号系列文档目录 Vue3ViteTypeScript安装 Element Plus安装与配置 主页设计与router配置 静态菜单设计 Pinia引入 文章目录 目录 系列文档目录 文章目录 前言 一、Aside设计 二、动态增加菜单 三.布局引用在Main中显示 参考文献: 前言 在本系列文档中&…

系列文档目录

Vue3+Vite+TypeScript安装

Element Plus安装与配置

主页设计与router配置

静态菜单设计

Pinia引入


文章目录

目录

系列文档目录

文章目录

前言

一、Aside设计

二、动态增加菜单

三.布局引用在Main中显示

参考文献:



前言

        在本系列文档中,将以一个实际的项目为例,逐步展示如何搭建菜单,设计主页布局,配置路由,实现静态和动态菜单等功能。


一、Aside设计

1.新建文件src\components\MainAsideCont.vue

完整代码如下:

// 主页左边的容器组件
<template><el-menudefault-active="2"class="el-menu-vertical-demo"  ><el-sub-menu index="1"><template #title><el-icon><location /></el-icon><span>Navigator One</span></template><el-menu-item-group><template #title><span>Group One</span></template><el-menu-item index="1-1">item one</el-menu-item><el-menu-item index="1-2">item two</el-menu-item></el-menu-item-group><el-menu-item-group title="Group Two"><el-menu-item index="1-3">item three</el-menu-item></el-menu-item-group><el-sub-menu index="1-4"><template #title><span>item four</span></template><el-menu-item index="1-4-1">item one</el-menu-item></el-sub-menu></el-sub-menu><el-menu-item index="2"><el-icon><icon-menu /></el-icon><template #title>Navigator Two</template></el-menu-item><el-menu-item index="3" disabled><el-icon><document /></el-icon><template #title>Navigator Three</template></el-menu-item><el-menu-item index="4"><el-icon><setting /></el-icon><template #title>Navigator Four</template></el-menu-item></el-menu>
</template><script lang="ts" setup>
import { ref } from 'vue'
import {Document,Menu as IconMenu,Location,Setting,
} from '@element-plus/icons-vue'</script><style>
.el-menu{height: 100%; /* 设置整个布局的高度为 100%,确保布局占满整个视口 */
}
.el-menu-vertical-demo:not(.el-menu--collapse) {width: 200px;min-height: 400px;
}
</style>

此处代码element plus官方代码,删除一些不需要部分,参考网址:http://element-plus.org/zh-CN/component/menu.html

2.调整Main.vue样式

只增加 style

<template><div class="common-layout"><el-container><el-aside ><MainAsideCont />       </el-aside><el-container><el-header>Header</el-header><el-main>Main</el-main></el-container></el-container></div></template><script lang="ts" setup>import { defineComponent } from 'vue';import MainAsideCont from '@/components/MainAsideCont.vue';</script><style lang="less" scoped>.common-layout {height: 100%; /* 设置整个布局的高度为 100%,确保布局占满整个视口 */width: 100%; /* 设置整个布局的宽度为 100%,确保布局占满整个视口 */.el-container {height: 100%; /* 确保内部的 el-container 也占满整个父容器的高度 */}.el-header {background-color: #fff ; /* 设置表头的背景色为深黑色 */color: #141515; /* 设置表头文字颜色为白色,以便在深色背景上更清晰 */display: flex; /* 使用 flex 布局,方便对齐内容 */align-items: center; /* 垂直居中对齐内容 */justify-content: center; /* 水平居中对齐内容 */font-size: 18px; /* 设置文字大小为 18px */font-weight: bold; /* 设置文字为加粗 */}.el-aside {background-color:rgba(242, 242, 242, 0.19); /* 设置侧边栏的背景色为浅灰色 */color: #333; /* 设置侧边栏文字颜色为深灰色 */display: flex; /* 使用 flex 布局,方便对齐内容 */    align-items: center; /* 垂直居中对齐内容 */justify-content: center; /* 水平居中对齐内容 */font-size: 16px; /* 设置文字大小为 16px */font-weight: normal; /* 设置文字为正常粗细 */height: 100%; /* 确保侧边栏高度占满 */width: 200px;}.el-main {background-color: #fff; /* 设置主内容区域的背景色为白色 */color: #333; /* 设置主内容区域文字颜色为深灰色 */padding: 20px; /* 添加内边距,使内容不紧贴边缘 */font-size: 14px; /* 设置文字大小为 14px */}}</style>

3、运行效果

二、动态增加菜单

1.增加src\views\home.vue

<template>
<h1> Home</h1>
</template>

2.增加src\views\SysSettings\UserInfo.vue

<template>
<h1> 用户信息</h1>
</template>

3.增加src\views\SysSettings\AccountSetting.vue

<template>
<h1> 账户设定</h1>
</template>

4.调整路由router\index.ts

重点:children定义

完整代码

import { createRouter, createWebHistory } from 'vue-router';
import Main from '@/views/Main.vue'; //
import Home from '@/views/Home.vue'
import UserInfo from '@/views/SysSettings/UserInfo.vue'
import AccountSetting from '@/views/SysSettings/AccountSetting.vue'const routes = [{path: '/',name: 'main',component: Main,children: [{path: 'home',name: 'home',component: Home,},{path: 'UserInfo',name: 'UserInfo',component: UserInfo,},{path: 'AccountSetting',name: 'AccountSetting',component:AccountSetting},],},];const router = createRouter({history: createWebHistory(),routes,
});export default router;

5.调整Aside

路径:src\components\MainAsideCont.vue

通过数据自动增加菜单,为后期调用API产生菜单做好准备

<template><el-menu:default-active="activeIndex"class="el-menu-vertical-demo"><!-- 渲染没有子菜单的项 --><el-menu-itemv-for="item in noChilden":key="item.index":index="item.index"@click="handlemenu(item)"><component class="icon" :is="item.icon"></component><span>{{ item.label }}</span></el-menu-item><!-- 渲染有子菜单的项 --><el-sub-menuv-for="item in hasChilden":key="item.index":index="item.index"><template #title><component class="icon" :is="item.icon"></component><span>{{ item.label }}</span></template><el-menu-itemv-for="subItem in item.children":key="subItem.index":index="subItem.index"@click="handlemenuchild(item, subItem)"><span>{{ subItem.label }}</span></el-menu-item></el-sub-menu></el-menu>
</template><script lang="ts" setup>
import { ref, computed, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import {Document,Setting,
} from '@element-plus/icons-vue';interface MenuItem {index: string;label: string;icon?: any;children?: MenuItem[];
}const menuData = ref<MenuItem[]>([{ index: 'Home', label: '首页', icon: Document },{index: 'SysSettings',label: '系统设置',icon: Setting,children: [{ index: 'UserInfo', label: '个人资料' },{ index: 'AccountSetting', label: '账户设置' },],},
]);const hasChilden = computed(() => menuData.value.filter(item => item.children && item.children.length > 0));
const noChilden = computed(() => menuData.value.filter(item => !item.children || item.children.length === 0));const activeIndex = ref('Home');
const router = useRouter();const handlemenu = (item: MenuItem) => {router.push(item.index);
};const handlemenuchild = (item: MenuItem, subItem: MenuItem) => {  router.push(subItem.index);
};
</script><style>
.el-menu {height: 100%; /* 设置整个布局的高度为 100%,确保布局占满整个视口 */
}
.el-menu-vertical-demo:not(.el-menu--collapse) {width: 200px;min-height: 400px;
}
.icon {margin-right: 8px; /* 图标与文字之间的间距 */font-size: 18px;   /* 图标的大小 */width:18px;height:18px;size:8px;color: #606266;    /* 图标的默认颜色 */vertical-align: middle; /* 垂直居中对齐 */
}/* 鼠标悬停时的样式 */
.icon:hover {color: #409eff; /* 鼠标悬停时图标的颜色 */
}</style>

6.运行效果

点击菜单时候,注意地址栏变化。

三.布局引用在Main中显示

1.修改src\views\main.vue

重点: <router-view></router-view>

完整代码:

<template><div class="common-layout"><el-container><el-aside ><MainAsideCont />       </el-aside><el-container><el-header>Header</el-header><el-main><router-view></router-view></el-main></el-container></el-container></div></template><script lang="ts" setup>import { defineComponent } from 'vue';import MainAsideCont from '@/components/MainAsideCont.vue';</script><style lang="less" scoped>.common-layout {height: 100%; /* 设置整个布局的高度为 100%,确保布局占满整个视口 */width: 100%; /* 设置整个布局的宽度为 100%,确保布局占满整个视口 */.el-container {height: 100%; /* 确保内部的 el-container 也占满整个父容器的高度 */}.el-header {background-color: #fff ; /* 设置表头的背景色为深黑色 */color: #141515; /* 设置表头文字颜色为白色,以便在深色背景上更清晰 */display: flex; /* 使用 flex 布局,方便对齐内容 */align-items: center; /* 垂直居中对齐内容 */justify-content: center; /* 水平居中对齐内容 */font-size: 18px; /* 设置文字大小为 18px */font-weight: bold; /* 设置文字为加粗 */}.el-aside {background-color:rgba(242, 242, 242, 0.19); /* 设置侧边栏的背景色为浅灰色 */color: #333; /* 设置侧边栏文字颜色为深灰色 */display: flex; /* 使用 flex 布局,方便对齐内容 */    align-items: center; /* 垂直居中对齐内容 */justify-content: center; /* 水平居中对齐内容 */font-size: 16px; /* 设置文字大小为 16px */font-weight: normal; /* 设置文字为正常粗细 */height: 100%; /* 确保侧边栏高度占满 */width: 200px;}.el-main {background-color: #fff; /* 设置主内容区域的背景色为白色 */color: #333; /* 设置主内容区域文字颜色为深灰色 */padding: 20px; /* 添加内边距,使内容不紧贴边缘 */font-size: 14px; /* 设置文字大小为 14px */}}</style>

2.运行效果


参考文献:

1.element plus menu:http://element-plus.org/zh-CN/component/menu.html

http://www.dtcms.com/wzjs/821007.html

相关文章:

  • 哪个网站的课件做的好百度广告平台电话
  • 河南中国建设厅官方网站制作简历的免费模板网站
  • 衡水 网站建设免费推广网站排名
  • 网站模板管理广州魔站建站
  • 财经网站建设方案国家企业信息系统公示系统下载
  • 厦门网站制作公司锡林郭勒盟建设局网站
  • 10个著名摄影网站安卓app公司开发
  • 做猎头要用的网站知乎如何搭建网站教程
  • 如何建立一个网站根目录自己可以做网站吗
  • 大连地区做网站博客网站开发利用数据库
  • 全屏网站模版物流网站开发公司
  • 海南创作什么网站2019wordpress使用手册
  • 公司官方网站制作黄山网站建设费用
  • 上海平台网站建设公司排名免费做团购网站的软件有哪些
  • 家居企业网站建设服务中国十大文旅策划公司
  • 用网站ip做代理服务器网站怎么做自然优化
  • 网站兼容9广州怎么做网站
  • 做外贸怎样上国外网站优秀网站的链接
  • 潮州网站制作门户网站集群建设方案
  • dw可以做有后台的网站么有域名了怎么建设网站
  • 安装iis8 添加网站asp网站授权码如何做
  • 东莞网站建设三合一静态html怎么部署到服务器
  • 网站怎么做直播功能我想承包小工程
  • 网站建设 的介绍设计网站页面要注意什么
  • 建设网站商城需要多少费用吗开发公司各部门职责
  • 有关网站建设文章是否有可能一个人完成网站开发
  • 有没有大人和小孩做的网站xrea免费 wordpress 加速
  • 桂阳网站设计开源多用户商城哪个好
  • wordpress站迁移后速度慢营销型网站的优缺点
  • 贵阳网站建设在哪里网站编程教学