vue 管理系统顶部tags浏览历史实现_第1页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、vue 管理系统顶部tags浏览历史实现不用任何vuex,污七八糟的办法,全在一个文件,粘贴即用 放到你想要的位置即可(此demo,放在了面包屑上面) 先安装 (监听某dom元素大小的包) npm install element-resize-detector tags.vue $t("router." + ) 刷新 关闭右侧 关闭其它 import elementresizedetectormaker from "element-resize-detector" export default data() return / 是否有箭头

2、arrowvisible: true, / 点击次数 num: 0, active: 0, tags: , / 右键的元素 contextmenu: index: 0, tag: , menuleft: 0, isshow: false ; , watch: $route() this.getthispage(); , tags() this.listenfun(this.$refs.tags, "tags"); , mounted() this.listenfun(this.$refs.box, "box"); var that = this; doc

3、ument.addeventlistener("click", function(e) that.contextmenu.isshow = false; ); , methods: / 监听可视区域宽,扫瞄器窗口大小转变执行 listenfun(monitor, dom) let boxwidth = this.$refs.box.offsetwidth, tagswidth = this.$refs.tags.offsetwidth, erd = elementresizedetectormaker(); erd.listento(monitor, ele = this.

4、$nexttick() = if ( (dom = "box" && ele.offsetwidth = tagswidth) | (dom = "tags" && ele.offsetwidth = currentp); if (index = -1) this.tags.push( name: currentp, path: currentpgae.path ); / 当前挑选页 this.active = this.tags.findindex(tag = tag.n

5、ame = currentp); , / 关闭标签 handleclose(index, tag) this.tags.splice(this.tags.indexof(tag), 1); if (index = this.tags.length) this.active = index - 1; this.$router.push(this.tagsindex - 1.path); else this.$router.push(this.tagsindex.path); , / 点击标签 clicktag(index, tag) this.active = index; th

6、is.$router.push(tag.path); , / 左侧按钮 handleclicktoleft() if (this.num 0) this.num-; this.$refs.box.style.transform = ——translatex(-$this.num * 200px)—— , / 右侧按钮 handleclicktoright() / 最后一个标签右测距离扫瞄器左侧距离 let lastchild = document .queryselectorall(".top_tags") this.tags

7、.length - 1.getboundingclientrect()。right; / 可视窗口的宽 let bodywidth = document.body.offsetwidth; / 右侧箭头48+右侧边距16 if (bodywidth - lastchild localstorage.setitem( "taginfo", json.stringify( active: this.active, tags: this.tags ) ); ); let taginfo = localstorage.getitem("taginfo") ? j

8、son.parse(localstorage.getitem("taginfo") : active: 0, tags: name: "firstpage1", path: "/first/page1" ; this.active = taginfo.active; this.tags = taginfo.tags; ; /deep/.el-tag-dark border-color: transparent; /deep/.el-tag-dark .el-tag_close color: 86909c; font-size: 16p

9、x; /deep/.el-tag-dark .el-tag_close:hover background: e7eaf0; .tags position: relative; overflow: hidden; .arrow width: 48px; text-align: center; cursor: pointer; background: fff; position: absolute; z-index: 1; &_left left: 0; top: 0; &_right right: 0; top: 0; &_content transition: 0.3s; white-space: nowrap; / padding: 0 16px; .top_tags margin-right: 8px; cursor: pointer; background: fff; font-size: 12px; font-weight: 400; color: 1d2129; .top_tags:hover, .active, .arrow:hover

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论