vue移动端实现(同一路由下)点击滑动转换多个菜单模块
收到如题的需求,不用跳转路由进行滑动切换,搜索了半天也没有搜到一个适合我的文章,那就只能自己写了,具体思路借鉴了vue不使用其他插件实现新闻app中左右滑动切换tab菜单和div内容的动画效果(移动端),稍加修改。
首先是效果图
(哪个大佬教教我怎么免费把视频做动图QAQ)
可以接受后台数据动态生成菜单列表,利用x轴拖动数据计算判断是否翻页,翻页也是利用x轴位移做的,因为目前只需要两页,所以只写了两个页面的位移,未来如果有更多模块需求再进行优化。
style样式
<style scope lang="scss">
body,
html .takeNum {
height: 100%;
width: 100%;
overflow: hidden;
font-family: PingFangSC;
background-size: 100% 100%;
}
.el-container {
height: 100%;
width: 100%;
}
.el-main {
width: 2000px;
display: flex;
.cback {
white-space: nowrap;
width: 1000px;
height: 40%;
.container {
width: 100%;
}
.cleft {
position: relative;
vertical-align: top;
display: inline-block;
.menuUl_1 {
flex-wrap: wrap;
justify-content: center;
}
.menuUl_2 {
flex-wrap: wrap;
}
}
.cright {
display: inline-block;
vertical-align: top;
position: relative;
}
.menuUl {
width: 1000px;
display: flex;
flex-wrap: wrap;
li {
width: 28%;
height: 200px;
margin-top: 50px;
margin-left: 20px;
display: flex;
padding-top: 40px;
justify-content: space-around;
background: orange;
background-size: 100% 100%;
border: #fff solid 1px;
border-radius: 10%;
.right {
width: 55%;
padding-right: 40px;
margin-left: 70px;
display: flex;
flex-direction: column;
align-items: flex-start;
p {
font-size: 34px;
color: #162d58;
}
span {
color: #69707d;
font-size: 24px;
margin-top: 20px;
}
i {
color: #162d58;
}