angular - Angular 9新项目-ng服务时未加载应用程序根
问题描述
我升级到 Angular 9 并在创建新项目后:ng new test - 当我在做时:ng serve - 页面未加载 app-root。当我在 index.html 中添加一些文本时 - 它显示文本但不显示 app-root。我降级到 Angular 8 和同样的问题。我在控制台中没有错误。我做了 ng build --prod 并且没有错误。
<!-- index.html -->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test1</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<p>test</p>
<app-root></app-root>
</body>
</html>
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'test1';
}
app.component.html
<p>Test inside app.component.html</p>
解决方案
推荐阅读
- sql-server - Gcloud Export to Google Storage from Cloud SQL instance as .sql file
- vue.js - How to correctly use vuex when migrating from vue-i18n to nuxt-i18n?
- python - 当“to”值为字符串时,graphene-django 忽略 Django ForeignKey 字段
- javascript - 使用公钥/私钥对 JWT 令牌进行编码
- python - 需要比较 pandas 中两个数据框的两列
- python - 在数据框中对相同的列值进行分组,并将相同值的总和添加为新列
- angular - Bootswatch 选择输入和文件输入无样式
- python - 无法使用 python 从 nsepy 中获取多只股票的数据
- javascript - 如何使用节点 ERR_ABORTED 404(未找到)将 script.js 正确添加到 html
- javascript - Storybook react-native web 问题 webpack.config