每日收获
1、绝对定位元素的自动居中新方法:
{
Position:fixed;
Left:0;right:0;
Top:0;bottom:0;
margin:auto
}
2、Vue项目中路由不变的时候强制刷新页面:
<router-view :key="$route.fullPath"></router-view>
$route.fullPath:全路径Url,只要key变化了就刷新页面,由于第一步设置的url后面都加一个时间戳,所以每次的url都是不一样的,也就达到了刷新页面的效果或者r:Math.random()也可以达到同样的效果。
3、vue单页面项目禁止返回到登录页面
destroyed(){
window.removeEventListener('popstate', this.goBack, false);
},
mounted(){
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.goBack, false);
}
},
methods:{
goBack(){
this.$router.push({path: '/property/proDataCenter/index'});//每次点击的的时候返回到当前页面
history.pushState(null, null, document.URL);
}
}
浙公网安备 33010602011771号