父页面跳转子页面,子页面返回父页面并强制刷新父页面【记录一下】

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30756923/article/details/83717296

<input type="hidden" id="refreshed" value="no">(父页面)

把下边的代码加入js(父页面调用)

if ((/iphone|ipod|ipad.*os 5/gi).test(navigator.appVersion)) {
  window.onpageshow = function (event) {
    if (event.persisted) {
      window.location.reload()
    }
  };
} else {
  onload = function () {
    var refreshedId = document.getElementById("refreshed");
if (refreshedId.value === "no") {
  refreshedId.value = "yes";
} else {
  refreshedId.value = "no";
      location.reload();
    }
  }
}

子页面 history.back(-1)返回父页面,父页面就会刷新。

父页面刷新方法如果有数据操作的话(如vue)

var app = new Vue({
                el:'#box',
                data:{
                    arr:['aaa','bbb']

                }

});

可以在刷新中写function(){

            // app.arr[index] = val;//这种方法不刷新页面(不重新渲染,但数据确实有了)

             app.$set(app.arr,arr的index,要设置的arr[index]的值);

}

猜你喜欢

转载自blog.csdn.net/qq_30756923/article/details/83717296
今日推荐