ElementUI之首页导航及左侧菜单(模拟实现)

目录

​编辑

前言

一、mockjs简介

1. 什么是mockjs

2. mockjs的用途

3. 运用mockjs的优势

二、安装与配置mockjs

1. 安装mockjs

2. 引入mockjs

2.1 dev.env.js

2.2  prod.env.js

2.3 main.js

三、mockjs的使用

1. 将资源中的mock文件夹复制到src目录下

2. 点击登陆进行模拟测试

四、总线的搭建

1. 案例图演示

2. 创建组件

AppMain.vue

LeftNav.vue

TopNav.vue

3. 配置路由与组件的关系

index.js

4. 实现登陆跳转主页

5. 最终代码

AppMain.vue

LeftNav.vue

TopNav.vue

main.js

最终演示效果


前言

        在之前的博客中与各位老铁分享一些有关Vue的知识,想必也给大家带来了一帮助与收获,例如:ElementUI实现登陆注册、vue-cli搭建SPA项目、路由等等。今天与各位老铁带来的是Element来搭建页面首页的导航及左侧的菜单模块。

一、mockjs简介

1. 什么是mockjs

        MockJS 是一款前端开发中常用的模拟数据生成工具,用于在开发过程中模拟接口返回数据。它可以帮助前端开发人员独立于后端接口进行开发和调试,提高开发效率。MockJS 提供了一套简单却强大的 API,可以根据指定的规则生成随机的模拟数据。通过 MockJS,开发者可以定义接口的返回结构、数据类型以及各种约束条件,例如字符串长度、数字范围、日期格式等,从而模拟真实的接口返回结果。

        MockJS 的使用非常灵活,可以配合其他前端框架(如 Vue、React、Angular)或纯 JavaScript 进行集成。它还支持在浏览器环境和 Node.js 服务器环境中运行,适用于各种场景下的模拟数据需求。

        通过使用 MockJS,开发者可以快速搭建前端开发环境,独立地进行开发和调试,在后端接口未完成或不可用的情况下,仍然能够保持项目的正常进行。同时,MockJS 还可以用于编写自动化测试用例,方便进行接口测试和调试工作。

2. mockjs的用途

        Mock.js 是一个模拟数据生成器,可以帮助前端开发者快速生成模拟数据,方便进行前端开发和前后端分离开发。具体的应用场景有:

  1. 前端开发时,可以用 Mock.js 生成模拟的接口数据,方便前端进行功能开发和调试,而不依赖后端接口的实现。

  2. 前后端分离开发时,前端可以使用 Mock.js 提供的模拟数据生成功能,随时随地进行开发和测试。当后端接口完成后,只需更改配置,将 Mock.js 替换为后端接口的请求即可。

  3. 在线教育平台等需要大量测试数据的应用场景中,可以使用 Mock.js 生成大量的随机数据,用于测试和演示。

  4. 在项目初期,当后端接口还未开发完成时,可以使用 Mock.js 生成模拟数据,给前端项目提供一些数据展示效果。

3. 运用mockjs的优势

优势主要包括:

  1. 数据类型丰富:MockJS支持生成随机的文本、数字、布尔值、日期、邮箱、链接、图片、颜色等,这有助于在开发过程中模拟各种数据情况,帮助开发者更好地进行测试和调试。
  2. 拦截Ajax请求:MockJS可以在不修改既有代码的情况下,拦截Ajax请求并返回模拟的响应数据,这对于在开发过程中模拟服务器响应或进行本地测试非常有用。
  3. 前后端分离:MockJS可以帮助前端独立于后端进行开发,这对于前后端分离的开发模式非常有益,可以加快开发进度和提高效率。
  4. 单元测试:MockJS的随机数据模拟功能可以帮助开发者在单元测试中增加测试的真实性,通过模拟各种场景来提高测试的完整性和可靠性。
  5. 无侵入性:MockJS不需要修改既有代码就可以进行拦截和模拟,这对于不希望修改生产代码的场景非常适用,比如在进行前端开发时进行接口测试。
  6. 简单易用:MockJS的接口符合直觉,易于使用,使得开发者可以快速上手并开始使用。
  7. 方便扩展:MockJS支持扩展更多数据类型,支持自定义函数和正则表达式,这使得MockJS可以满足更多的开发需求。二、

二、安装与配置mockjs

1. 安装mockjs

在项目的目录下进入cmd终端窗口,输入一下指令进行安装。

npm i mockjs -D

注:-D表示只在开发环境中使用

2. 引入mockjs

2.1 dev.env.js

module.exports = merge(prodEnv, {NODE_ENV: '"development"',MOCK: 'true'
})

2.2  prod.env.js

module.exports = {NODE_ENV: '"production"',MOCK: 'false'
}

2.3 main.js

在动态main.js中加载mockjs,在开发环境下才会使用,生产环境不会使用。

//开发环境下才会引入mockjs
process.env.MOCK && require('@/mock') 

三、mockjs的使用

1. 将资源中的mock文件夹复制到src目录下

 该文件下的json文件夹中的login-mock.js是用来创造模拟数据的,index.js是用来将数据与登陆请求进行绑定的。

2. 点击登陆进行模拟测试

 点击多次登陆后,code可能发生改变(-1/0),但是message的长度不一。

 模拟当前登陆成功与失败,不进行后端交互

Login.vue

<template><div class="login"><template><div class="login-wrap"><el-form class="login-container"><h1 class="title">君易官网登录</h1><el-form-item label=""><el-input type="text" v-model="username" placeholder="登录账号" autocomplete="off"></el-input></el-form-item><el-form-item label=""><el-input type="password" v-model="password" placeholder="登录密码" autocomplete="off"></el-input></el-form-item><el-form-item><el-button type="primary" style="width:100%;" @click="doSubmit()">提交</el-button></el-form-item><el-row style="text-align: center;margin-top:-10px"><el-link type="primary">忘记密码</el-link><el-link type="primary" @click="gotoRegister()">用户注册</el-link></el-row></el-form></div></template></div></template><script>// import axios from 'axios'// import qs from 'qs'export default {name: 'Login',data() {return {msg: 'Welcome to Your Vue.js App',username: '',password: ''}},methods: {gotoRegister() {// 跳转注册页面this.$router.push('/Register');},doSubmit() {// 接受参数let params = {username : this.username,password : this.password};// 打印输出查看console.log(params);// 定义请求参数的访问地址var url = this.axios.urls.SYSTEM_USER_DOLOGIN;// 想后端发送post请求this.axios.post(url, params).then(r => {// 打印console.log(r);// 输入的账号密码正确则弹出登陆成功提示,反之弹出密码或账号有误提示// if (r.data.success) {//   this.$message({//     message: r.data.msg,//     type: 'success'//   });// } else {//   this.$message.error(r.data.msg);// }this.$message({message: r.data.message,type: r.data.code ==0 ? 'success' : 'error'});}).catch(e => {console.log(e);});}}}
</script><style scoped>.login-wrap {box-sizing: border-box;width: 100%;height: 100%;padding-top: 10%;background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjEzNjFweCIgaGVpZ2h0PSI2MDlweCIgdmlld0JveD0iMCAwIDEzNjEgNjA5IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dH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LDkwLjQxNjY2NjciIGlkPSJQYXRoLTI1IiBzdHJva2U9IiNDRkRBRTYiIHN0cm9rZS13aWR0aD0iMS4xNjY2NjY2NyI+PC9wYXRoPgogICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtNSIgZmlsbD0iI0MxRDFFMCIgY3g9IjE1Ni45MTY2NjciIGN5PSI4Ljc1IiByPSI4Ljc1Ij48L2NpcmNsZT4KICAgICAgICAgICAgICAgICAgICA8Y2lyY2xlIGlkPSJPdmFsLTUtQ29weS0zIiBmaWxsPSIjQzFEMUUwIiBjeD0iMzkuMDgzMzMzMyIgY3k9IjE0OC43NSIgcj0iNS4yNSI+PC9jaXJjbGU+CiAgICAgICAgICAgICAgICAgICAgPGNpcmNsZSBpZD0iT3ZhbC01LUNvcHktMiIgZmlsbC1vcGFjaXR5PSIwLjYiIGZpbGw9IiNEMURFRUQiIGN4PSI4Ljc1IiBjeT0iMzMuMjUiIHI9IjguNzUiPjwvY2lyY2xlPgogICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtNS1Db3B5LTQiIGZpbGwtb3BhY2l0eT0iMC42IiBmaWxsPSIjRDFERUVEIiBjeD0iMjQzLjgzMzMzMyIgY3k9IjMwLjMzMzMzMzMiIHI9IjUuODMzMzMzMzMiPjwvY2lyY2xlPgogICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtNS1Db3B5LTUiIGZpbGw9IiNFMEI0QjciIGN4PSIxNzUuNTgzMzMzIiBjeT0iMjMyLjc1IiByPSI1LjI1Ij48L2NpcmNsZT4KICAgICAgICAgICAgICAgIDwvZz4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+);/* background-color: #112346; */background-repeat: no-repeat;background-position: center right;background-size: 100%;}.login-container {border-radius: 10px;margin: 0px auto;width: 350px;padding: 30px 35px 15px 35px;background: #fff;border: 1px solid #eaeaea;text-align: left;box-shadow: 0 0 20px 2px rgba(0, 0, 0, 0.1);}.title {margin: 0px auto 40px auto;text-align: center;color: #505458;}
</style>

 运行效果

四、总线的搭建

1. 案例图演示

2. 创建组件

如案例演示图所示,我们需要创建三个组件来完成效果搭建,由于三个组件是公共部分所以复制方到components文件下,将所需图片放到assets文件下。

AppMain.vue

<template><el-container class="main-container"><el-aside v-bind:class="asideClass"><LeftNav></LeftNav></el-aside><el-container><el-header class="main-header"><TopNav></TopNav></el-header><el-main class="main-center">Main</el-main></el-container></el-container>
</template><script>// 导入组件import TopNav from '@/components/TopNav.vue'import LeftNav from '@/components/LeftNav.vue'// 导出模块export default {};
</script>
<style scoped>.main-container {height: 100%;width: 100%;box-sizing: border-box;}.main-aside-collapsed {/* 在CSS中,通过对某一样式声明! important ,可以更改默认的CSS样式优先级规则,使该条样式属性声明具有最高优先级 */width: 64px !important;height: 100%;background-color: #334157;margin: 0px;}.main-aside {width: 240px !important;height: 100%;background-color: #334157;margin: 0px;}.main-header,.main-center {padding: 0px;border-left: 2px solid #333;}
</style>

LeftNav.vue

<template><el-menu default-active="2" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" background-color="#334157"text-color="#fff" active-text-color="#ffd04b" :collapse="collapsed" :collapse-transition="bb"><!-- <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b"> --><div class="logobox"><img class="logoimg" src="../assets/img/logo.png" alt=""></div><el-submenu index="1"><template slot="title"><i class="el-icon-location"></i><span>导航一</span></template><el-menu-item-group><template slot="title">分组一</template><el-menu-item index="1-1">选项1</el-menu-item><el-menu-item index="1-2">选项2</el-menu-item></el-menu-item-group><el-menu-item-group title="分组2"><el-menu-item index="1-3">选项3</el-menu-item></el-menu-item-group><el-submenu index="1-4"><template slot="title">选项4</template><el-menu-item index="1-4-1">选项1</el-menu-item></el-submenu></el-submenu><el-menu-item index="2"><i class="el-icon-menu"></i><span slot="title">导航二</span></el-menu-item><el-menu-item index="3" disabled><i class="el-icon-document"></i><span slot="title">导航三</span></el-menu-item><el-menu-item index="4"><i class="el-icon-setting"></i><span slot="title">导航四</span></el-menu-item></el-menu>
</template>
<script>export default {}
</script>
<style>.el-menu-vertical-demo:not(.el-menu--collapse) {width: 240px;min-height: 400px;}.el-menu-vertical-demo:not(.el-menu--collapse) {border: none;text-align: left;}.el-menu-item-group__title {padding: 0px;}.el-menu-bg {background-color: #1f2d3d !important;}.el-menu {border: none;}.logobox {height: 40px;line-height: 40px;color: #9d9d9d;font-size: 20px;text-align: center;padding: 20px 0px;}.logoimg {height: 40px;}
</style>

TopNav.vue

<template><!-- <el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal" @select="handleSelect" background-color="#545c64"text-color="#fff" active-text-color="#ffd04b"><el-menu-item index="1">处理中心</el-menu-item><el-submenu index="2"><template slot="title">我的工作台</template><el-menu-item index="2-1">选项1</el-menu-item><el-menu-item index="2-2">选项2</el-menu-item><el-menu-item index="2-3">选项3</el-menu-item><el-submenu index="2-4"><template slot="title">选项4</template><el-menu-item index="2-4-1">选项1</el-menu-item><el-menu-item index="2-4-2">选项2</el-menu-item><el-menu-item index="2-4-3">选项3</el-menu-item></el-submenu></el-submenu><el-menu-item index="3" disabled>消息中心</el-menu-item><el-menu-item index="4"><a href="https://www.ele.me" target="_blank">订单管理</a></el-menu-item></el-menu> --><el-menu class="el-menu-demo" mode="horizontal" background-color="#334157" text-color="#fff" active-text-color="#fff"><el-button class="buttonimg"><img class="showimg" :src="collapsed?imgshow:imgsq" @click="doToggle()"></el-button><el-submenu index="2" class="submenu"><template slot="title">超级管理员</template><el-menu-item index="2-1">设置</el-menu-item><el-menu-item index="2-2">个人中心</el-menu-item><el-menu-item @click="exit()" index="2-3">退出</el-menu-item></el-submenu></el-menu>
</template><script>export default {}
</script><style scoped>.el-menu-vertical-demo:not(.el-menu--collapse) {border: none;}.submenu {float: right;}.buttonimg {height: 60px;background-color: transparent;border: none;}.showimg {width: 26px;height: 26px;position: absolute;top: 17px;left: 17px;}.showimg:active {border: none;}
</style>

3. 配置路由与组件的关系

index.js

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'import AppMain from '@/components/AppMain'
import LeftNav from '@/components/LeftNav'
import TopNav from '@/components/TopNav'import Login from '@/views/Login'
import Register from '@/views/Register'Vue.use(Router)export default new Router({routes: [ //默认首页{path: '/',name: 'Login',component: Login}, {path: '/Register',name: 'Register',component: Register}, {path: '/Login',name: 'Login',component: Login}, {path: '/AppMain',name: 'AppMain',component: AppMain,children;[{path: '/LeftNav',name: 'LeftNav',component: LeftNav}, {path: '/TopNav',name: 'TopNav',component: TopNav}]}]
})

4. 实现登陆跳转主页

 this.$router.push('/AppMain');

 

 这只是半成品,后还需进行调整才能显示样式和效果。

5. 最终代码

AppMain.vue

<template><el-container class="main-container"><el-aside v-bind:class="asideClass"><LeftNav></LeftNav></el-aside><el-container><el-header class="main-header"><TopNav></TopNav></el-header><el-main class="main-center">Main</el-main></el-container></el-container>
</template><script>// 导入组件import TopNav from '@/components/TopNav.vue'import LeftNav from '@/components/LeftNav.vue'// 导出模块export default {components: {TopNav,LeftNav},data() {return {asideClass: 'main-aside'}},created(){this.$root.Bus.$on('xxx',v=>{this.asideClass = v ? 'main-aside-collapsed' : 'main-aside';});}};
</script>
<style scoped>.main-container {height: 100%;width: 100%;box-sizing: border-box;}.main-aside-collapsed {/* 在CSS中,通过对某一样式声明! important ,可以更改默认的CSS样式优先级规则,使该条样式属性声明具有最高优先级 */width: 64px !important;height: 100%;background-color: #334157;margin: 0px;}.main-aside {width: 240px !important;height: 100%;background-color: #334157;margin: 0px;}.main-header,.main-center {padding: 0px;border-left: 2px solid #333;}
</style>

LeftNav.vue

<template><el-menu default-active="2" class="el-menu-vertical-demo"  background-color="#334157"text-color="#fff" active-text-color="#ffd04b" :collapse="collapsed" ><!-- <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b"> --><div class="logobox"><img class="logoimg" src="../assets/img/logo.png" alt=""></div><el-submenu index="1"><template slot="title"><i class="el-icon-location"></i><span>导航一</span></template><el-menu-item-group><template slot="title">分组一</template><el-menu-item index="1-1">选项1</el-menu-item><el-menu-item index="1-2">选项2</el-menu-item></el-menu-item-group><el-menu-item-group title="分组2"><el-menu-item index="1-3">选项3</el-menu-item></el-menu-item-group><el-submenu index="1-4"><template slot="title">选项4</template><el-menu-item index="1-4-1">选项1</el-menu-item></el-submenu></el-submenu><el-menu-item index="2"><i class="el-icon-menu"></i><span slot="title">导航二</span></el-menu-item><el-menu-item index="3" disabled><i class="el-icon-document"></i><span slot="title">导航三</span></el-menu-item><el-menu-item index="4"><i class="el-icon-setting"></i><span slot="title">导航四</span></el-menu-item></el-menu>
</template>
<script>export default {data() {return{collapsed:false}},created(){this.$root.Bus.$on('xxx',v=>{this.collapsed = v;});}}
</script>
<style>.el-menu-vertical-demo:not(.el-menu--collapse) {width: 240px;min-height: 400px;}.el-menu-vertical-demo:not(.el-menu--collapse) {border: none;text-align: left;}.el-menu-item-group__title {padding: 0px;}.el-menu-bg {background-color: #1f2d3d !important;}.el-menu {border: none;}.logobox {height: 40px;line-height: 40px;color: #9d9d9d;font-size: 20px;text-align: center;padding: 20px 0px;}.logoimg {height: 40px;}
</style>

TopNav.vue

<template><!-- <el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal" @select="handleSelect" background-color="#545c64"text-color="#fff" active-text-color="#ffd04b"><el-menu-item index="1">处理中心</el-menu-item><el-submenu index="2"><template slot="title">我的工作台</template><el-menu-item index="2-1">选项1</el-menu-item><el-menu-item index="2-2">选项2</el-menu-item><el-menu-item index="2-3">选项3</el-menu-item><el-submenu index="2-4"><template slot="title">选项4</template><el-menu-item index="2-4-1">选项1</el-menu-item><el-menu-item index="2-4-2">选项2</el-menu-item><el-menu-item index="2-4-3">选项3</el-menu-item></el-submenu></el-submenu><el-menu-item index="3" disabled>消息中心</el-menu-item><el-menu-item index="4"><a href="https://www.ele.me" target="_blank">订单管理</a></el-menu-item></el-menu> --><el-menu class="el-menu-demo" mode="horizontal" background-color="#334157" text-color="#fff" active-text-color="#fff"><el-button class="buttonimg"><img class="showimg" :src="collapsed?imgshow:imgsq" @click="doToggle()"></el-button><el-submenu index="2" class="submenu"><template slot="title">超级管理员</template><el-menu-item index="2-1">设置</el-menu-item><el-menu-item index="2-2">个人中心</el-menu-item><el-menu-item @click="exit()" index="2-3">退出</el-menu-item></el-submenu></el-menu>
</template><script>export default {data() {return {collapsed: false,imgshow: require('@/assets/img/show.png'),imgsq: require('@/assets/img/sq.png')}},methods: {doToggle(){this.collapsed = !this.collapsed;// 将是否折叠的变量放入总线this.$root.Bus.$emit('xxx',this.collapsed);},exit(){this.$router.push("/");}}}
</script><style scoped>.el-menu-vertical-demo:not(.el-menu--collapse) {border: none;}.submenu {float: right;}.buttonimg {height: 60px;background-color: transparent;border: none;}.showimg {width: 26px;height: 26px;position: absolute;top: 17px;left: 17px;}.showimg:active {border: none;}
</style>

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'//开发环境下才会引入mockjs
process.env.MOCK && require('@/mock')// 新添加1
import ElementUI from 'element-ui'
// 新添加2,避免后期打包样式不同,要放在import App from './App';之前
import 'element-ui/lib/theme-chalk/index.css'import App from './App'
import router from './router'Vue.use(ElementUI);import axios from '@/api/http'
import VueAxios from 'vue-axios'Vue.use(VueAxios,axios)Vue.config.productionTip = false/* eslint-disable no-new */
new Vue({el: '#app',router,data(){return{Bus:new Vue()}},components: { App },template: '<App/>'
})

最终演示效果

这就是总线的基础使用了 

         本期博客与大家分享了有关mockjs及总线的一些使用,并在项目中进行运用演示,希望大家能够三连加关注支持博主,后期会对该项目进行扩展及完善,敬请期待。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/145017.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Unity Build-In管线的SurfaceShader剖析_PBS光照函数】

Unity Build-In管线的SurfaceShader剖析 在Unity Build-In 管线&#xff08;Universal Render Pipeline&#xff09;新建一个Standard Surface Shader文件里的代码如下&#xff1a;选中"MyPBR.Shader"&#xff0c;在Inspector面板&#xff0c;打开"Show generat…

Zygisk-IL2CppDumper对抗方案

众所周知&#xff0c;Unity引擎中有两种脚本编译器&#xff0c;分别是 Mono 和 IL2CPP 。这两种脚本编译器各有优势&#xff0c;同时也存在一些安全性问题&#xff0c;本文将从游戏安全角度对其进行分析并提供对策。 Mono 是由跨平台的开源.NET 实现&#xff0c;它允许开发者使…

Unity如何实现TreeView

前言 最近有一个需求,需要实现一个TreeView的试图显示,开始我一直觉得这么通用的结构,肯定有现成的UI组件或者插件可以使用,结果,找了好久,都没有找到合适的插件,有两个效果差强人意。 最后在回家的路上突然灵光一闪,想到了一种简单的实现方式,什么插件都不用,仅使用…

《学术小白学习之路12》进阶-基于Python实现中文文本的DTM主题动态模型构建

《学术小白学习之路》基于Python实现中文文本的DTM主题动态模型构建 一、数据选择二、数据预处理三、输入数据ID映射词典构建四、文档加载成构造语料库五、DTM模型构建与结果分析六、结果进行保存七、保存模型一、数据选择 所选取的数据集是论文摘要,作为实验数据集,共计12条…

从1开始的Matlab(快速入门)

MATLAB软件版本&#xff1a;MATLAB R2016b 本文是博主从零开始学Matlab的记录&#xff0c;适合第一次接触Matlab的同学阅读。 一、基础介绍 1.1界面认识 1.2变量命名 注&#xff1a;Matlab中的注释 %% 独占一行的注释&#xff08;有上下横线分割&#xff09; % 普通注释 …

react项目优化

随着项目体积增大&#xff0c;打包的文件体积会越来越大&#xff0c;需要优化&#xff0c;原因无非就是引入的第三方插件比较大导致&#xff0c;下面我们先介绍如何分析各个文件占用体积的大小。 1.webpack-bundle-analyzer插件 如果是webpack作为打包工具的项目可以使用&…

Vivado与Notepad++关联步骤

填写内容 先看"关联步骤"再看此处&#xff1a; 在“editor”栏中填写 Notepad的路径&#xff0c;并加上[file name] -n[line number]&#xff0c; 这里我的 Notepad 的路径为 C:/Program Files (x86)/Notepad/notepad.exe &#xff1b; 故这里我就填上以下内容即可…

xxl-job 2.2之后版本高版本executor未授权访问漏洞

xxl-job 低版本executor未授权访问 低版本的executor未授权访问漏洞是 POST /run HTTP/1.1 Host: your-ip:9999 Accept-Encoding: gzip, deflate Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like G…

rabbitMQ死信队列快速编写记录

文章目录 1.介绍1.1 什么是死信队列1.2 死信队列有什么用 2. 如何编码2.1 架构分析2.2 maven坐标2.3 工具类编写2.4 consumer1编写2.5 consumer2编写2.6 producer编写 3.整合springboot3.1 架构图3.2 maven坐标3.3 构建配置类&#xff0c;创建exchange&#xff0c;queue&#x…

【Leetcode】 450. 删除二叉搜索树中的节点

给定一个二叉搜索树的根节点 root 和一个值 key&#xff0c;删除二叉搜索树中的 key 对应的节点&#xff0c;并保证二叉搜索树的性质不变。返回二叉搜索树&#xff08;有可能被更新&#xff09;的根节点的引用。 一般来说&#xff0c;删除节点可分为两个步骤&#xff1a; 首先…

“童”趣迎国庆 安全“童”行-柿铺梁坡社区开展迎国庆活动

“金秋十月好心境&#xff0c;举国欢腾迎国庆。”国庆节来临之际&#xff0c;为进一步加强梁坡社区未成年人爱国主义教育&#xff0c;丰富文化生活&#xff0c;营造热烈喜庆、文明和谐的节日氛围。9月24日上午&#xff0c;樊城区柿铺街道梁坡社区新时代文明实践站联合襄阳市和时…

Spring IOC(控制反转)与DI(依赖注入)

定义 IOC(Inversion of Control)&#xff0c;即控制反转&#xff1a;对象的创建控制权不再由程序来执行&#xff0c;而是交由给Spring容器处理。简单的说程序不需要进行new操作&#xff0c;对象直接由Spring容器自动创建。 DI(Dependency Injection)&#xff0c;即依赖注入&am…

阿木实验室PrometheusV1.1安装+Ubuntu 20.04

1. 安装ros-noetic 2. 安装Mavros包 sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras3. GeographicLib wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh这里可以使用代理 &#xff1a;wg…

9.30小任务

消息队列实现进程之间通信方式 实现了父子进程之间的通信 #include <myhead.h>//消息结构体 typedef struct {long msgtype; //消息类型char data[1024]; //消息正文 }Msg_ds;#define SIZE sizeof(Msg_ds)-sizeof(long) //正文大小int main(int arg…

Bug:elementUI样式不起作用、Vue引入组件报错not found等(Vue+ElementUI问题汇总)

前端问题合集&#xff1a;VueElementUI 1. Vue引用Element-UI时&#xff0c;组件无效果解决方案 前提&#xff1a; 已经安装好elementUI依赖 //安装依赖 npm install element-ui //main.js中导入依赖并在全局中使用 import ElementUI from element-ui Vue.use(ElementUI)如果此…

idea环境下如何打包可运行jar?

工作中有时候偶尔写一些工具类、小程序&#xff0c;可是java程序员制作一个可运行jar实在折腾&#xff0c;利用idea开发环境&#xff0c;可以快速打包自己的可运行jar。具体怎么操作呢&#xff1f; 创建一个空白的java项目并完成自己的程序开发 完成java代码&#xff1a; /**…

(Vue3)defineOptions、defineModels Pinia及持久化

Vue3.3新特性defineOptions v-model和defineModel 开启特性vite.config.js中加配置 重启架子&#xff08;试验性质&#xff09;npm run dev Pinia Vue最新的状态管理工具&#xff0c;代替Vuex Pinia配置创建项目时自动添加 安装 npm install pinia 创建一个 pinia 实例 (根 s…

Bluespec SytemVerilog 握手协议接口转换

01、引言 由于接口控制信号上的差异&#xff0c;要实现Bluespec SystemVerilog(BSV)生成的代码和外部Verilog代码之间的正确交互是一件比较麻烦同时容易出错的事情。在BSV中, 模块之间的交互都是基于Action或ActionValue这两类method完成。下图展示了使用BSV设计的某一模块的接…

8.2 Jmeter if控制器使用

前提&#xff1a;jmeter脚本需要用到if控制器&#xff0c;if判断如果查询不到&#xff0c;则去新增。 1、添加if控制器 线程组-->逻辑控制器-->如果(if)控制器 1&#xff09;、Expression (must evaluate to true or false) &#xff1a;表达式&#xff08;值必须是tru…

数据结构算法--6 希尔排序和计数排序

希尔排序 希尔排序与插入排序原理相同&#xff0c;希尔排序是一种分组插入排序算法 > 首先取一个整数d1n/2&#xff0c;将元素分为d1个组&#xff0c;每组相邻两元素之间距离为d1&#xff0c;在各组内之间插入排序。 > 取第二个整数d2n/2&#xff0c;重复上述分组排序…