Giter VIP home page Giter VIP logo

Comments (12)

wmz0806 avatar wmz0806 commented on September 13, 2024

我也遇到这个问题, 修改了下源码, 目前还没有遇到什么问题

【update in 2015.10.27】以下方法已被证实有问题

  1. 首先:(大概7252行)
    var state = history.state;
    if(!state) {
      var id = this.genStateID();

       // 此部分注释
      //this.pushState(location.href, id);
      //this.pushBack({
        //url: location.href,
        //pageid: "#" + currentPage[0].id,
        //id: id
      //});

      this.setCurrentStateID(id);
    }
  1. 大概7351行 修改为
  Router.prototype.back = function(url) {
      var stack = JSON.parse(this.stack.getItem("back"));
      if(stack.length) {
        history.back();
      } else if(url) { //判断了下url的值
        location.href = url;
     }
  };
  1. 大概 7387 行 修改为
Router.prototype.onpopstate = function(d) {
    var state = d.state;

    if(!state) {//刷新再后退导致无法取到state
      this._back(); //主要添加这句代码
      return;
    }

  //......
}

from sui-mobile.

Mrlilili avatar Mrlilili commented on September 13, 2024

thx,快过1个月了终于有人回答,感动哭,我最后的解决方案也是把整个router给注释掉了

from sui-mobile.

wmz0806 avatar wmz0806 commented on September 13, 2024

我也最近 用到这个框架玩玩 发现这个坑

from sui-mobile.

Mickey- avatar Mickey- commented on September 13, 2024

任何场景都要点两次才能后退吗?是不是需要满足某种情况?我的场景点一次就可以的

from sui-mobile.

Mrlilili avatar Mrlilili commented on September 13, 2024

你做的是单页应用不? 单页应用返回不会出现两侧后退的问题,其它都会出现

from sui-mobile.

wmz0806 avatar wmz0806 commented on September 13, 2024

就是 第一 进入页面会 pushState 一个当前浏览器的 地址进history 意思就是 第一次进入 就能后退 如果这时候用户点了后退 后面所有的 后退都会失效

from sui-mobile.

Mickey- avatar Mickey- commented on September 13, 2024

是的,这边SPA应用都OK,添加external展开成多页后出现了这个问题。
@w353284782 这样改后单页应用的history机制会受影响吗,建议也测试一下。

都OK的话连着注释发一个PR共建吧,回归确认后我们merge进来:)

from sui-mobile.

djfly avatar djfly commented on September 13, 2024

这bug都没人管吗?我也遇到这个问题,用了楼主的代码也不管用

from sui-mobile.

openks avatar openks commented on September 13, 2024

@djfly 直接使用 location.href 算了

from sui-mobile.

djfly avatar djfly commented on September 13, 2024

location.href 必须要先存下上一页url吧?

from sui-mobile.

Mickey- avatar Mickey- commented on September 13, 2024

近期会修复,方法可能不尽完善,有时间的也请协助一起review。欢迎提供建议或PR
#52

P.S. @w353284782 你的方法会导致SPA应用的路由问题

from sui-mobile.

Mickey- avatar Mickey- commented on September 13, 2024

修复了有一阵了。。忘了关联issue,这里补一下,请使用0.5.2版本,还有问题欢迎提出

from sui-mobile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.