自定义角度7中的“后退”按钮导航

问题描述

我有一个包含5个步骤和5个屏幕的组件页面。当我单击“后退”按钮时,它返回到最后一个组件。单击前四次后退按钮时,我已添加代码以停止导航到上一页,但是在执行步骤1时,我陷入了代码困境,需要两次单击后退按钮来返回上一组件。

    this.loc.onPopState(() => {
      if(this.step == "step2"){
        history.pushState(null,null,window.location.href);
        this.step = "step1";
        document.getElementById('truckprogress').style.width = "0%";
      }else if(this.step == "step3"){
        history.pushState(null,window.location.href);
        this.step = "step2";
        document.getElementById('truckprogress').style.width = "20%";
      }else if(this.step == "step4"){
        history.pushState(null,window.location.href);
        this.step = "step3";
        document.getElementById('truckprogress').style.width = "40%";
      }else if(this.step == "step5"){
        history.pushState(null,window.location.href);
        this.step = "step4";
        document.getElementById('truckprogress').style.width = "80%";
      }else if(this.step == "step1"){
       // history.go(-1);
      }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...