窗口位置哈希重置

时间:2019-12-05 17:54:27

标签: javascript hash window

window.location.hash变量有一个奇怪的问题... 我正在编写SPA,并设置describe("Foo", () => { it("should bubble the event up and call parent's handleClick", () => { const handleClick = jest.spyOn(Foo.prototype, 'handleClick') //spy on handleClick function const wrapper = mount(<Foo />); wrapper.find('button').simulate('click'); //finding the button and simulating click expect(handleClick).toHaveBeenCalledTimes(1) //verify function was called after click simulation }) }) 转到另一页。在基本路由器中,我正在监听“ hashchange”窗口事件。从第一页更改为第二页工作正常。但是从第二到第三,变量为空。我有window.location.hash = "nextRoute"

知道为什么突然重置吗?

感谢您的帮助!

到目前为止,这里我已经编写了一些代码:

在用户类别中:

window.location.hash = ""

在路由器中:

    public editUser(): void {
        context_menu.hide("user_context_menu");
        router.goto("/useredition");
    }

此外,该事件被两次调用...

我只是一步一步地运行了代码,它起作用了。可能是同步问题吗?

0 个答案:

没有答案
相关问题