问题描述
我们目前正在开发一个用 Angular 编写的 chrome 扩展。设置是将整个 Angular 应用程序构建为 manifest.json 中的内容脚本
正如您在下面的代码中看到的,除了 contentPage.js
之外的所有内容都来自 angular 源。
"content_scripts": [
{
"matches": ["http://*/*","https://*/*","file://*/*.pdf"],"js": ["contentPage.js","polyfills.js","runtime.js","main.js"],"css": ["styles.css"],"run_at": "document_idle"
}
],
问题来了,我们遇到了路由问题。 任何路由重定向都相对于当前网页 url 进行导航,因为它是一个内容脚本。
假设我目前在 https://stackoverflow.com/questions
,然后调用 this.router.navigate(['/home'])
将导航到 https://stackoverflow.com/questions/home
。
如何在整个 Angular 应用程序嵌入为内容脚本的 chrome 扩展上下文中使用 Angular 路由?
编辑:
在调查问题后,它似乎只在延迟加载的路由上不起作用。正常路由的路径正确解析,但延迟加载路由的路径解析与当前网页 url 相关,而不是 chrome 扩展
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)