element+vue 动态修改favcion及系统名称
首先要有favcion上传功能,修改后将favcion及系统名称存入数据库,具体可搜索添加,目前主要介绍变更favcion;
登录时将获取的当前用户信息存入localstory,APP.VUE页面,获取localstory内存放的数据,如下:
created () { if (localStorage.getItem('menus') !== null) { this.currentUser = JSON.parse(localStorage.getItem('currentUser')) document.title = this.currentUser.programName var link = document.querySelector("link[rel~='icon']") if (!link) { link = document.createElement('link') link.rel = 'icon' document.getElementsByTagName('head')[0].appendChild(link) } if (this.currentUser.favicon !== null) { // this.URL为文件统一下载路径,favcion存放的文件的相对路径 link.href = this.URL + this.currentUser.favicon } } }
html页面
`
更改后重新登陆即可生效;