Javascript 未捕获(承诺中)类型错误:无法读取属性';拆分';未定义的?使用React路由器的下一个应用程序

Javascript 未捕获(承诺中)类型错误:无法读取属性';拆分';未定义的?使用React路由器的下一个应用程序,javascript,reactjs,react-router,react-router-dom,html5-history,Javascript,Reactjs,React Router,React Router Dom,Html5 History,未捕获(承诺中)TypeError:无法读取未定义的属性“split”?使用React路由器的下一个应用程序 在寻找那个错误时,我遇到了,但他们在使用,而我在使用 当用户使用浏览器的“后退”按钮进行导航时,会发生此错误 不确定从我的代码中发布什么,但这是从router.js产生的错误: onlyAHashChange(as) { if (!this.asPath) return false; const [oldUrlNoHash,

未捕获(承诺中)TypeError:无法读取未定义的属性“split”?使用React路由器的下一个应用程序

在寻找那个错误时,我遇到了,但他们在使用,而我在使用

当用户使用浏览器的“后退”按钮进行导航时,会发生此错误

不确定从我的代码中发布什么,但这是从
router.js产生的错误:

   onlyAHashChange(as) {
        if (!this.asPath)
            return false;
        const [oldUrlNoHash, oldHash] = this.asPath.split('#');
        const [newUrlNoHash, newHash] = as.split('#');
        // Makes sure we scroll to the provided hash if the url/hash are the same
        if (newHash && oldUrlNoHash === newUrlNoHash && oldHash === newHash) {
            return true;
        }
        // If the urls are change, there's more than a hash change
        if (oldUrlNoHash !== newUrlNoHash) {
            return false;
        }
        // If the hash has changed, then it's a hash only change.
        // This check is necessary to handle both the enter and
        // leave hash === '' cases. The identity case falls through
        // and is treated as a next reload.
        return oldHash !== newHash;
    }
有趣的是,我正在使用
浏览器路由器
。具体而言,我的
URL
配置文件如下所示:

http://localhost:8016/login

代码中的引用似乎引用了如下内容:

http://localhost:8016#login

更新
在听到并思考谢丽尔在讨论中所添加的内容(见下面的评论)后,这促使我更仔细地研究错误的来源。原来它是在一个名为
next server

的包中,请仔细检查
asPath
as
的类型是否为字符串。@programmerRaj谢谢我的朋友,这主意不错!它们确实是弦!什么意思?您是否更改了它并使它们成为字符串,或者它们已经是字符串了。还有,它现在可以工作了吗?这可能与任何事情都没有关系,但我对你说的这句话的意思感到困惑:“我是在使用浏览器后退按钮导航时自然发现它的。”?我不确定这是否与你的问题有关,我只确定我不明白;-)@programmerRaj我没有更改它们它们已经是字符串了。。。