2312970463@qq.com 4 years ago
parent
commit
6b75e00001
2 changed files with 19 additions and 3 deletions
  1. 6 3
      src/main.js
  2. 13 0
      src/router.js

+ 6 - 3
src/main.js

@@ -11,9 +11,12 @@ import 'element-ui/lib/theme-chalk/index.css';
 Vue.config.productionTip = false
 Vue.use(ElementUI);
 
-//页面跳转时,页面位置重置为顶部
- router.afterEach((to,from,next) => {
-      window.scrollTo(0,0);
+
+ router.afterEach((to,from,next) => {
+	 //页面跳转时,页面位置重置为顶部
+      window.scrollTo(0,0);
+	  //修改页面title
+	  window.document.title = to.meta.title == undefined?'荆州红十字会':to.meta.title
  })
 
 new Vue({

+ 13 - 0
src/router.js

@@ -1,6 +1,19 @@
 import Vue from 'vue'
 import Router from 'vue-router'
 
+const routerPush = Router.prototype.push  
+
+Router.prototype.push = function push(location) {
+ 
+  if(typeof(location)=="string"){
+    var Separator = "&";
+    if(location.indexOf('?')==-1) { Separator='?'; }
+    location = location + Separator + "random=" + Math.random();
+  }
+
+  return routerPush.call(this, location).catch(error => error)
+}
+
 Vue.use(Router)
 
 export default new Router({