【Angular】问题汇总

本文汇总了Angular开发过程中常见的几个问题及其解决方案,包括主页标题栏样式无效、端口被占用及TypeError异常等,并提供了详细的步骤指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Angular学习问题汇总

一、 主页标题栏样式不起作用(添加jquery和bootstrap文件,但不起作用)

解决方案一:Src目录下index.html文件,在下的中添加引用:
​​在这里插入图片描述
代码:

<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
  <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
  <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

解决方案二:
产生原因:Bootstrap版本为3.3.7的版本,需要重新下载这一版本的依赖包,同时需要在全局style.css样式文件中导入Bootstrap。
(引用:@import “~bootstrap/dist/css/bootstrap.css”;)
在这里插入图片描述

二、Port 4200 is already in use. Use '--port' to specify a different port.
解决方案一:杀死占用4200端口号的进程
cd C:\\windows\system32
netstat -ano | findstr :4200

在这里插入图片描述

TaskKill.exe /F /PID 10364

在这里插入图片描述
解决方案二:更换端口号

node_modules  ->@angular -> cli -> lib ->config -> schema.json

在这里插入图片描述
修改4200即可
在这里插入图片描述
解决方案三:更换本次端口号
正常的启动命令是ng serve,本次使用ng serve --port启动即可。

三、 TypeError: this.titleFilter.valueChanges.debounceTime is not a function

解决方案一:
产生效果:界面只显示左侧的搜索栏目
原因:Angular版本问题,目前使用版本为Angluar6,所以product组件中的product.component.ts中的方法中的debounceTime(500)不可用
解决:修改product组件中的product.component.ts如下,同时之前需要做的引用 import 'rxjs/Rx’直接删除即可。
​​在这里插入图片描述

解决方案二:
​​在这里插入图片描述

四、The serve command requires to be run in an Angular project, but a project definition could not be found.

在这里插入图片描述
解决方案:

update @angular/cli
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值