Angular 6 - Chrome 在 IOS 上 - 路由器问题

5

我正在开发一个 Angular 6 的网站,但在 IOS 的 Chrome 浏览器(iPad、iPhone)上出现了一个奇怪的问题。

如果直接访问每个链接,每个页面都可以正确地渲染。但是,当我在任何页面中单击任何链接时,就会生成 NavigationError,类似于以下内容:

TypeError: Argument 1 ('other') to Node.contains must be an instance of Node
TypeError: Argument 1 ('node') to Node.insertBefore must be an instance of Node

在IOS中调试Chrome确实很困难,所以很难获取更多信息。

我的网站在其他任何浏览器和操作系统上都运行良好,包括Firefox(windows, linux),Chrome (windows and linux),Safari (ios, osx, windows)。

有人有任何想法从哪里开始查找问题吗?

谢谢!

1个回答

0

显然,只有在Google Chrome iOS上存在此代码时才会出现问题:

let script = window['document'].createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1');
window['document'].body.appendChild(script);
window['__onGCastApiAvailable'] = function (isAvailable) { /*Do chromecast initialization*/}

所以我添加了这个条件:

if(!navigator.userAgent.match('CriOS'))

问题已解决。 我真的不知道为什么Cast框架会破坏Angular路由。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接