从版本开始,13.0.0将.angular在根目录中生成一个文件夹,该文件夹会被 git 忽略,其中包含一个cache缓存构建的文件夹。
如何删除(或清除)此缓存?
当我尝试运行命令ng lint --fixcli 时抛出此错误:
An unhandled exception occurred: Cannot find builder "@angular-devkit/build-angular:tslint".
See "C:\Users\MOE89A~1.ZAR\AppData\Local\Temp\ng-Ijc3an\angular-errors.log" for further details.
Run Code Online (Sandbox Code Playgroud)
我的 lint 确认angular.json:
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/wepod-app/tsconfig.app.json",
"projects/wepod-app/tsconfig.spec.json",
"projects/wepod-app/e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
Run Code Online (Sandbox Code Playgroud)
我的package.json:
{
"name": "wepod-clients",
"version": "3.2.3",
"scripts": {
"ng": "ng",
"start": "node patch.js && ng serve",
"build": "node patch.js && node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng run wepod-app:app-shell:production && ng run wepod-app:auth-standalone:production",
"server": "npm run build && http-server -p …Run Code Online (Sandbox Code Playgroud) 我目前对角度和自学还比较陌生。以前一切都工作正常,直到我决定将很多新东西导入到我的项目中。简而言之,我发现我可以删除 node_modules 并运行 npm install。删除它后,当我运行 npm install 时出现以下错误。
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: appla-katta@0.0.0
npm ERR! Found: @angular/common@12.2.16
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"~12.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^14.0.0 || ^15.0.0" from @angular/cdk@14.0.2
npm ERR! node_modules/@angular/cdk
npm ERR! @angular/cdk@"14.0.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, …Run Code Online (Sandbox Code Playgroud) 我简化了我的问题:
<div *ngIf="layout1" class="layout1">
<div class="sidebar-layout1">
some items
</div>
<child-component [something]="sth"></child-component>
</div>
<div *ngIf="!layout1" class="layout2">
<child-component [something]="sth">
<p>some content...</p>
</child-component>
</div>
Run Code Online (Sandbox Code Playgroud)
我有一个父组件,可以使用正常布局(layout1)和全屏布局(layout2)(在全屏模式下,子组件应该处于全屏状态)。问题是,当我使用 *ngIf 更改布局时,子组件将被销毁并生成一个新组件。我想要拥有相同的实例,并且不要丢失子组件的重要信息并避免一些 api 调用。
有没有什么方法可以实现子组件不会被破坏,或者有没有比 ngIf 更好的方法?
我只需要一个子组件实例来实现父组件中的不同布局。
运行后npm install,首先出现错误jasmine-core。
解决后,我收到此错误:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: client@0.0.0
npm ERR! Found: @angular/compiler@11.0.9
npm ERR! node_modules/@angular/compiler
npm ERR! @angular/compiler@"^11.0.7" from the root project
npm ERR! peer @angular/compiler@"11.0.9" from @angular/compiler-cli@11.0.9
npm ERR! node_modules/@angular/compiler-cli
npm ERR! dev @angular/compiler-cli@"~11.0.7" from the root project
npm ERR! peer @angular/compiler-cli@"^11.0.0" from @angular-devkit/build-angular@0.1100.7
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"^0.1100.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency: …Run Code Online (Sandbox Code Playgroud) 在阅读有关 Angular 13 新增功能的博客时,我遇到了以下声明:
由于 Angular 包使用具有子路径模式的 Node.js 包导出功能,因此不再支持 v12.20 之前的 Node.js 版本。
那么,我想知道“子路径模式”是什么意思?这里的例子将非常受欢迎。
我正在从 Angular 16 迁移到 17,遇到了需要用新语法替换*ngForand*ngIf的所有用法的问题( and和ngSwitch@for@if@switch所有用法的问题。
我知道 v17 仍然支持旧语法,但有没有办法迁移它们或使用正则表达式将它们替换为新形式?
当我运行npm run build它时,执行ng build -c production构建将按预期完成。但命令提示符将充满此警告:
Warning: 303 rules skipped due to selector errors:
0% -> Unmatched selector: %
20% -> Unmatched selector: %
53% -> Unmatched selector: %
40% -> Unmatched selector: %
43% -> Unmatched selector: %
70% -> Unmatched selector: %
80% -> Unmatched selector: %
90% -> Unmatched selector: %
...
Run Code Online (Sandbox Code Playgroud)
如何解决这个警告?
package.json:
{
"name": "wepod-clients",
"version": "3.2.3",
"scripts": {
"ng": "ng",
"start": "node patch.js && ng serve",
"serve-auth": "ng run …Run Code Online (Sandbox Code Playgroud) 我收到这个错误
属性绑定 ngIf 未被嵌入模板上的任何指令使用。确保属性名称拼写正确并且所有指令都列在“@NgModule.declarations”中
即使你在我跑步时也能正常工作ng serve。
当我将 Angular 更新为v13.
我已经尝试重新启动Vscode并重新安装Angular Language Service并安装以前版本的Angular Language Service ...它们都不起作用..
我的app.module.ts:
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
imports: [CommonModule, BrowserModule, AppRoutingModule],
providers: [],
bootstrap: [AppComponent],
exports: [CommonModule, BrowserModule],
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud) 在我的角度项目中,我有这样的代码:
this.swUpdate.available.subscribe(() => {
...
});
Run Code Online (Sandbox Code Playgroud)
它工作正常,但给了我关于被弃用的警告activated。
我应该怎么做才能解决这个警告?
angular ×10
typescript ×8
angular-cli ×4
javascript ×4
node.js ×2
npm ×2
npm-install ×2
angular13 ×1
angular17 ×1
components ×1
deprecated ×1
directive ×1
module ×1
node-modules ×1
package.json ×1
rxjs ×1
sass ×1
tslint ×1