【问题标题】:Angular 6 Safari router related errorAngular 6 Safari路由器相关错误
【发布时间】:2018-08-08 15:33:43
【问题描述】:

该网站可在 Chrome 和 Firefox 中运行。在 Safari 中,您可以一次导航到任何路由器页面。第二次单击链接时会出现以下错误:Error: Uncaught (in promise): SyntaxError: The string did not match the expected pattern 并且路由器插座中没有加载任何内容。您也可以直接加载任何网址,一切正常。问题总是在单击路由器链接之后。无论您关注哪个 url 或遵循什么顺序,路由器链接在崩溃前只能工作一次。

这里是路由模块。我很确定它不会提供任何线索,但是哦,好吧......

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 { }

【问题讨论】:

    标签: angular safari angular-routing angular-router angular-routerlink


    【解决方案1】:

    我发现了问题。它似乎与路由器无关,而是与 Angular 如何处理 Meta 类方法有关。如果在标签不存在的情况下调用任何查找元标签(如 updateTag()removeTag())的方法,Safari 会崩溃并抛出该神秘错误。出于某种原因,Chrome、Firefox 和 Edge 继续工作,甚至不会抛出错误。

    该错误已报告至https://github.com/angular/angular/issues/25427

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-19
      • 2018-12-27
      • 1970-01-01
      • 1970-01-01
      • 2019-01-05
      • 2018-12-15
      • 1970-01-01
      • 2018-02-02
      相关资源
      最近更新 更多