Angular 6 Safari 路由器相关错误
Angular 6 Safari router related error
该站点可在 Chrome 和 Firefox 中运行。在 Safari 中,您可以导航到任何路由器页面 一次。第二次单击 link 时,出现以下错误:Error: Uncaught (in promise): SyntaxError: The string did not match the expected pattern
并且路由器插座中没有加载任何内容。您也可以直接加载任何 url,一切正常。问题总是在点击路由器 links 之后。 url 或您的跟随顺序无关紧要,路由器 link 在崩溃前只工作一次。
这是路由模块。我很确定它不会提供任何线索,但是哦......
import { AuthGuard } from './auth.guard';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{
path: '',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'registro',
loadChildren: './register/register.module#RegisterModule'
},
{
path: 'usuarios',
loadChildren: './user-list/user-list.module#UserListModule',
canActivate: [AuthGuard]
},
{
path: 'usuario',
loadChildren: './user/user.module#UserModule',
canActivate: [AuthGuard]
},
{
path: 'mi-perfil',
loadChildren: './user-edit/user-edit.module#UserEditModule',
canActivate: [AuthGuard]
},
{
path: 'actividad',
loadChildren: './new-edit-event/new-edit-event.module#NewEditEventModule',
canActivate: [AuthGuard]
},
{
path: 'actividades',
loadChildren: './event-list/event-list.module#EventListModule',
canActivate: [AuthGuard]
},
{
path: 'actividad',
loadChildren: './event/event.module#EventModule',
canActivate: [AuthGuard]
},
{
path: 'mensajes',
loadChildren: './chat/chat.module#ChatModule',
canActivate: [AuthGuard]
},
{
path: 'articulos',
loadChildren: './article-list/article-list.module#ArticleListModule',
canActivate: [AuthGuard]
},
{
path: 'articulo',
loadChildren: './article/article.module#ArticleModule',
canActivate: [AuthGuard]
},
{
path: 'legal',
loadChildren: './legal/legal.module#LegalModule',
canActivate: [AuthGuard]
},
{
path: 'admin',
loadChildren: './admin/admin.module#AdminModule',
canActivate: [AuthGuard]
},
{
path: '**',
redirectTo: ''
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, {scrollPositionRestoration: 'enabled'})],
exports: [RouterModule]
})
export class AppRoutingModule { }
我发现了问题。它似乎与 Router 无关,而是与 Angular 如何处理 Meta class 方法有关。如果在标签不存在时调用任何查找元标签(如 updateTag()
或 removeTag()
的方法),Safari 会崩溃并抛出该神秘错误。由于某种原因,Chrome,Firefox 和 Edge 继续工作,甚至不抛出错误。
报告
该站点可在 Chrome 和 Firefox 中运行。在 Safari 中,您可以导航到任何路由器页面 一次。第二次单击 link 时,出现以下错误:Error: Uncaught (in promise): SyntaxError: The string did not match the expected pattern
并且路由器插座中没有加载任何内容。您也可以直接加载任何 url,一切正常。问题总是在点击路由器 links 之后。 url 或您的跟随顺序无关紧要,路由器 link 在崩溃前只工作一次。
这是路由模块。我很确定它不会提供任何线索,但是哦......
import { AuthGuard } from './auth.guard';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{
path: '',
loadChildren: './home/home.module#HomeModule'
},
{
path: 'registro',
loadChildren: './register/register.module#RegisterModule'
},
{
path: 'usuarios',
loadChildren: './user-list/user-list.module#UserListModule',
canActivate: [AuthGuard]
},
{
path: 'usuario',
loadChildren: './user/user.module#UserModule',
canActivate: [AuthGuard]
},
{
path: 'mi-perfil',
loadChildren: './user-edit/user-edit.module#UserEditModule',
canActivate: [AuthGuard]
},
{
path: 'actividad',
loadChildren: './new-edit-event/new-edit-event.module#NewEditEventModule',
canActivate: [AuthGuard]
},
{
path: 'actividades',
loadChildren: './event-list/event-list.module#EventListModule',
canActivate: [AuthGuard]
},
{
path: 'actividad',
loadChildren: './event/event.module#EventModule',
canActivate: [AuthGuard]
},
{
path: 'mensajes',
loadChildren: './chat/chat.module#ChatModule',
canActivate: [AuthGuard]
},
{
path: 'articulos',
loadChildren: './article-list/article-list.module#ArticleListModule',
canActivate: [AuthGuard]
},
{
path: 'articulo',
loadChildren: './article/article.module#ArticleModule',
canActivate: [AuthGuard]
},
{
path: 'legal',
loadChildren: './legal/legal.module#LegalModule',
canActivate: [AuthGuard]
},
{
path: 'admin',
loadChildren: './admin/admin.module#AdminModule',
canActivate: [AuthGuard]
},
{
path: '**',
redirectTo: ''
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, {scrollPositionRestoration: 'enabled'})],
exports: [RouterModule]
})
export class AppRoutingModule { }
我发现了问题。它似乎与 Router 无关,而是与 Angular 如何处理 Meta class 方法有关。如果在标签不存在时调用任何查找元标签(如 updateTag()
或 removeTag()
的方法),Safari 会崩溃并抛出该神秘错误。由于某种原因,Chrome,Firefox 和 Edge 继续工作,甚至不抛出错误。