• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
小码哥-倩倩
博客园    首页    新随笔    联系   管理    订阅  订阅

每日收获

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);
  }
}
posted @ 2019-05-05 17:37  小码哥-倩倩  阅读(90)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3