Vue和Element UI 路由跳转,侧边导航的路由跳转,侧边栏拖拽
首先看布局,因为我的用于页面显示的 是通过重定向定位到登陆页的,然后通过登陆页跳转到主页。项目中用到了点击侧边栏的跳转,所以记录下来,方便有需要的人用到~
- 阐述
(1).content{ display:flex;} 一定要有,否则在拖拽时会出现换行的情况
(2)resize 要相对于父级绝对定位
{{ item.name }} {{ item.name }} {{ el.name }} 已选指标 拖动可自定义指标顺序 账户名称 以上指标将横向固定 {{ item.name }}import { ref } from "vue"; import { vDraggable } from "vue-draggable-plus"; import { Close } from "@element-plus/icons-vue"; const sideList = ref([ { id: 1, name: "基本信息", child: [ { id: 1, name: "账号名称" }, { id: 2, name: "账户ID" }, { id: 3, name: "账户主体" } ] }, { id: 2, name: "财务流水", child: [ { id: 1, name: "共享赠款支出(¥)" }, { id: 2, name: "账户总支出" }, { id: 3, name: "账户现金支出" } ] }, { id: 3, name: "展现数据", child: [ { id: 1, name: "消耗" }, { id: 2, name: "展示数" }, { id: 3, name: "平均千次展现费用" } ] }, { id: 4, name: "转化数据", child: [ { id: 1, name: "转换数" }, { id: 2, name: "转换陈本" }, { id: 3, name: "转换率" } ] }, { id: 5, name: "转化数据(计费时间)", child: [ { id: 1, name: "转化数(计费时间)" }, { id: 2, name: "转化成本(计费时间)" }, { id: 3, name: "深度转化次数(计费时间)" } ] }, { id: 6, name: " APP下载数据", child: [ { id: 1, name: "安卓下载开始数" }, { id: 2, name: "安卓下载开始成本" }, { id: 3, name: "安卓下载开始率" } ] }, { id: 7, name: "视频数据", child: [ { id: 1, name: "播放数" }, { id: 2, name: "有效播放数" }, { id: 3, name: "有效播放率" } ] }, { id: 8, name: "落地页及门店数据", child: [ { id: 1, name: "点击电话按钮" }, { id: 2, name: "表单提交" }, { id: 3, name: "地图搜索" } ] }, { id: 9, name: "附加创意", child: [ { id: 1, name: "附加创意电话按钮点击" }, { id: 2, name: "附加创意在线咨询点击" }, { id: 3, name: "附加创意表单按钮点击" } ] }, { id: 10, name: "互动数据", child: [ { id: 1, name: "新增关注数" }, { id: 2, name: "点赞数" }, { id: 3, name: "评论提交数" } ] }, { id: 11, name: " 直播间数据", child: [ { id: 1, name: "直播间观看数" }, { id: 2, name: "直播间超过1分钟观看数" }, { id: 3, name: "直播间关注数" } ] }, { id: 12, name: "游戏行业", child: [ { id: 1, name: "当日付费金额" }, { id: 2, name: "当日付费ROI" }, { id: 3, name: "激活24h首次付费数" } ] }, { id: 13, name: "线索收集", child: [ { id: 1, name: "有效获客" }, { id: 2, name: "乘客首次下单数" }, { id: 3, name: "回访—加好友(计费时间)" } ] } ]); const categoryClick = (item) => { sideList.value.forEach((el) => (el.checked = false)); item.checked = !item.checked; const element = document.getElementById("chen" + item.id); if (element) { element.scrollIntoView({ behavior: "smooth" }); } }; const count = ref(0); const removeItem = (id) => { drag.value = drag.value.filter(item => item.id != id); }; // const domeRef = ref(null); // const handleClick = (MouseEvent) => { // e.preventDefault(); // }; //拖拽 const drag = ref([ { id: 1, name: "账户ID" }, { id: 2, name: "备注" }, { id: 3, name: "项目" }, { id: 4, name: "登录邮箱" }, { id: 5, name: "账户余额(元)" }, { id: 6, name: "消耗" }, { id: 7, name: "点击率" }, { id: 8, name: "深度转化成本" }, { id: 9, name: "首次付费率" }, { id: 10, name: "APP内访问" }, { id: 11, name: "app内下单" } ]); const dragClick = (item) => { drag.value.forEach((el) => (el.checked = false)); item.checked = !item.checked; }; function onUpdate() { console.log("update"); } function onAdd() { console.log("add"); } function onRemove() { console.log("remove"); } ::v-deep .el-scrollbar { overflow: hidden; height: 100%; position: static !important; } ::v-deep .el-checkbox__input.is-checked .el-checkbox__inner { background-color: #409eff;; //border-color: var(--el-checkbox-checked-input-border-color); } //隐藏滚动条 ::-webkit-scrollbar-thumb { border-radius: 5px; background-color: rgb(255, 255, 255, 0.2);; } ::-webkit-scrollbar { width: 10px; height: 10px; } //搜索框 .top-wrapper { display: flex; justify-content: flex-start; margin-bottom: 16px; } .top-wrapper .search { width: 250px; } .el-input { position: relative; font-size: 14px; } .el-input__inner { -webkit-appearance: none; background-color: #fff; background-image: none; border-radius: 4px; border: 1px solid #dcdfe6; box-sizing: border-box; color: #606266; display: inline-block; height: 40px; line-height: 40px; outline: 0; padding: 0 15px; transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1); width: 100%; font-size: inherit; -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1); } .el-dialog .el-dialog__body .el-input .el-input__inner { padding-left: 8px; color: #333; } .el-input .el-input__inner { height: 32px; line-height: 32px; border-radius: 2px; } //侧边栏 .indicator-side .indicator-category { padding-left: 16px; font-size: 14px; line-height: 40px; color: #333; cursor: pointer; display: block; } .indicator-side .indicator-category-active { color: #197afb; background-color: #d6eaff; } //中间基本信息 .indicator-block { padding: 16px 0 0 24px; border-bottom: 1px solid #eaebec; } .indicator-group { display: flex; justify-content: flex-start; } .indicator-title { margin-bottom: 16px; font-weight: 700; color: #333; } .el-checkbox__input.is-checked .el-checkbox__label{ color: #409eff; } .el-checkbox__label { color: #333; } .el-checkbox__label, .el-radio__label { font-size: 12px; color: #666; } .el-checkbox__label { display: inline-block; padding-left: 1px; line-height: 19px; font-size: 12px; } //拖拽 .indicator-drag .indicator-content { padding: 0 16px; } .indicator-drag .drag-title { font-size: 14px; font-weight: 700; line-height: 100%; color: #333; } .indicator-drag .drag-sec { margin: 8px 0; font-size: 12px; line-height: 100%; color: #999; } .indicator-drag .drag-sepreate { position: relative; margin: 16px 0 0; font-size: 12px; color: #999; text-align: center; } .indicator-drag .indicator-limit-many { max-height: 445px; padding: 0 16px; margin-top: 16px; overflow-x: hidden; overflow-y: auto; } .indicator-drag .mg2 { margin-bottom: 2px; } .indicator-drag .drag-block { position: relative; height: 40px; //width: 134px; padding: 0 30px 0 36px; overflow: hidden; line-height: 40px; text-overflow: ellipsis; white-space: nowrap; background-color: #fff; border-bottom: 1px solid #e8eaec; } .indicator-drag .drag-block .close { position: absolute; top: 13px; line-height: 100%; color: #cecece; cursor: pointer; } //滑动条 .infinite-list { width: 160px; height: 300px; padding: 0; margin: 0; list-style: none; } .infinite-list .infinite-list-item { display: flex; align-items: center; justify-content: center; height: 40px; padding-left: 16px; font-size: 14px; background: #409eff; margin: 10px; color: #409eff; } .infinite-list .infinite-list-item + .list-item { margin-top: 10px; } //中部 .indicator-wrapper { display: flex; width: 832px; height: 516px; border: 1px solid #eaebec; border-radius: 4px; } //侧边栏 .indicator-side { flex-shrink: 0; width: 160px; overflow: auto; border-right: 1px solid #eaebec; } //选择器 .indicator-body { width: 672px; overflow: auto; scroll-behavior: smooth; } //右边 .indicator-drag { position: absolute; top: 0; right: 0; flex-shrink: 0; width: 216px; //height: 676px; padding: 25px 0; overflow: auto; background-color: #f8f8f9; border-right: 1px solid #eaebec; }
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。