zoukankan      html  css  js  c++  java
  • spa 单页面解决浏览器back front 问题

    1.angular router

      reloadOnSearch:true(default) | false

        默认为true,当url的hash发生改变,页面新渲染,component会重新加载(初始化);

        false,当url的hash发生改变,页面不重新渲染,component不会重新加载(初始化);

    2.改变url的hash

      window.history.pushState({}, null, '?tab=home');改方法可以直接改变url的hash,并加入history;

    当前url为http://localhost:8888
    执行前:
    http://localhost:8888
    window.history.pushState({}, null, '?tab=home');
    执行后:
    http://localhost:8888?tab=home

         window.location.hash 取或者设置url的hash值,直接在url上面加入hash:

    当前url为http://localhost:8888
    执行前:http://localhost:8888
    window.location.hash = 'name=test';
    执行后:http:
    //localhost:8888?tab=home#name=test

         window.location.search 取或者url 通过pushState的值,方法类似window.history.pushState({}, null, '?tab=home');

     
  • 相关阅读:
    hadoop面试
    常用脚本
    1.kafka
    2.flink
    java面试
    Hbase 项目
    linux 2>&1 和 &的意思
    Jetbrains系列产品重置试用方法
    解决GitHub网页githubusercontent地址无法访问问题
    stylus 成熟的写法
  • 原文地址:https://www.cnblogs.com/rengised/p/6248525.html
Copyright © 2011-2022 走看看