Angular 4路由
我的角度4路由不起作用. > Angular 4路由与Angular 2不同.请只能遇到类似问题的人使用Angular 4评论.似乎有很多变化,我按照2017年的指导方针设置了我的路线.将旧解决方案标记为此只会让人感到困惑和无益 – 特别是因为我是Angular的新手并且只有4的经验.我不想使用HashLocationStrategy * 我可以导航到我的域,然后使用我的菜单组件在页面之间导航,但是当我输入mydomain / home时,我看到一个空白页面.看起来其他人问过有关Angular早期版本的类似问题,但我看不到任何人有更新的设置. 我有 import { routes } from './app.router'; 在app.module.ts中 和 import { ModuleWithProviders } from '@angular/core'; import { Routes,RouterModule } from '@angular/router'; import { HomeComponent } from './home/home.component'; import { ArtComponent } from './art/art.component'; import { MusicComponent } from './music/music.component'; import { EventsComponent } from './events/events.component'; export const router: Routes = [ { path: '',redirectTo: 'home',pathMatch: 'full'},{ path: 'home',component: HomeComponent },{ path: 'art',component: ArtComponent },{ path: 'music',component: MusicComponent },{ path: 'events',component: EventsComponent } ]; export const routes: ModuleWithProviders = RouterModule.forRoot(router); 在app.router.ts中 我担心我对Angular很新! 这些是Chrome Inspector中的错误: polyfills.71b130084c52939ca448.bundle.js:1 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help,check https://xhr.spec.whatwg.org/. (anonymous) @ polyfills.71b130084c52939ca448.bundle.js:1 firebug-lite.js:30396 [Deprecation] 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead. getMembers @ firebug-lite.js:30396 home Failed to load resource: the server responded with a status of 404 () 我已经将这个问题缩小到类似于这里的构建问题:https://github.com/angular/angular-cli/issues/5113 这个问题似乎没有一个令人满意的答案 – 如果有人能告诉我在哪里指出我的–base-href来使我的构建工作? 解决方法
结果我的Angular代码没问题.问题出在我的托管服务提供商的服务器上.我需要在我的dist包中包含一个.htaccess文件
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |