之前自己做的那个购物页面点击变化,就出现了隐藏头部栏返回之后flex布局失效问题,其实解决方法很简单,就是让需要出现头部栏的页面返回的是“flex”
获取的元素.style.display = 'flex'
用平时的思想就是索引号小于2的话需要出现则会采用显示’block‘,但是display隐藏会使得flex布局失效(我不知道可不可把他理解为是因为flex布局层次低于diasplay隐藏,所以被盖住了)
if(e.target.dataset.id > 2){
document.querySelector('header').style.display='none'
}
传统思想需要的tob栏就显示
//else document.querySelector('header').style.display='block'
把显示block换成flex即可还原,且不会被隐藏
else document.querySelector('header').style.display='flex'