杂记篇

1.将数据存在缓存里:

sessionStorage.setItem('名字', JSON.stringify(数据));   
 
2.从缓存里拿数据:
JSON.parse(sessionStorage.getItem('名字'));
sessionStorage.removeItem('名字');
this.$router.replace({ query });
 
3.动态名class名
:class="['right-icon',(topMsg.warnType==='2' || topMsg.topMsg==='3')?'warn':'remind']"
:class="['默认名', {{'border':isShowMore} }]"
 
4.将数组对象更换某个key名:
JSON.parse(JSON.stringify(item).replace(/"roleList(需要更换key)":/g, '"tagList(需要key)":'));
 
5.将滚动置顶
this.$refs.list.$el.scrollIntoView();
 
6.锚点(移动到某个字母)进行滚动列表
document.querySelectorAll('.sc-scroller-module')[i].scrollIntoView();
 
7.js改变css
元素.style.top = `${top + height / 2 - iconHeight / 2}px`
 
8.判断是ios还是安卓机型
/android/gi.test(navigator.userAgent)
 
9.html 返回上一页
$router.back()
 

猜你喜欢

转载自www.cnblogs.com/xiaoxiaocheng/p/12503797.html