加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 4路由

发布时间:2020-12-17 07:16:10 所属栏目:安全 来源:网络整理
导读:Could people stop suggesting this post be tagged with angular-4 routing? I am aware of that tag. My problem,however,was not to do with the routing of Angular 4 – it was kindof a mistake question coz I didn’t understand what was going on

Could people stop suggesting this post be tagged with angular-4
routing? I am aware of that tag. My problem,however,was not to do
with the routing of Angular 4 – it was kindof a mistake question coz I didn’t
understand what was going on at the time. The solution here will not
help people who want help with actual Angular 4 routing so I disagree that it
should be tagged as such and I will keep rejecting that alteration. I reiterate: It was a mistake to try to launch an angular web-app using a standard hosting package without first understanding PHP,nodejs,the dist folder and a whole bunch of other stuff. I see a lot of people making similar mistakes,but they need to know it is not routing problem so much as a not-knowing-about-websites problem,and they should just do as I did and buckle down and learn stuff.

我的角度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文件

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读