javascript - 新组件未呈现 Angular
问题描述
我是 Angular 的初学者。我想在我的项目中创建一个新组件,但是当我在 index.html 中使用它时它没有呈现。
我使用了这个命令:
ng new test
cd test
ng generate component radio
在我编辑了我的 index.html 之后:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</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>
<app-root>Loading...</app-root>
<app-radio>Loading...</app-radio>
</body>
</html>
我做的结果ng serve
:
app works!
Loading...
在 app/radio/radio.component.html 我有这个代码自动生成:
<p>
radio works!
</p>
那么,为什么它不在我的浏览器中呈现?我的错误在哪里?
解决方案
您的 app-root 是您的 Angular 应用程序的应用程序容器。
<app-radio></app-radio>
在 app.component.html 中设置您的内容,您应该会看到它。
希望有帮助!
推荐阅读
- javascript - REACT 上的“FirebaseApp”类型上不存在属性“auth”
- c - 在 Visual Studio 代码中运行 openMP 代码的问题
- python - python_speech_features 包安装失败
- regex - 正则表达式匹配不包含斜杠的字符串
- jquery - jQuery - 根据 attr 值仅获取选中复选框的唯一值
- python - python: instaloader 得到关于 40K 429 错误的评论
- heroku - 有什么方法可以优化 cpu 中的 pytorch 推理吗?
- javascript - Quarkus POST 多部分 JSON 水果
- katalon-studio - 无法运行 katalon.exe
- react-native - React Native 中的简单 Sqlite 选择不显示行