小编Bra*_*don的帖子

您尝试使用标准 CSS 解析器解析 SCSS;在 Angular 12 更新后使用 postcss-scss 解析器重试

从 Angular 11 更新到 12 后,ng serve现在抛出错误:

Error: /Users/btaylor/work/angular-apps/mdsl-authoring/assets/scss/_colors.scss:1:4: Unknown word
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser

Error: /Users/btaylor/work/angular-apps/mdsl-authoring/assets/scss/custom-bootstrap.scss:1:1: Unknown word
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser

Error: /Users/btaylor/work/angular-apps/mdsl-authoring/assets/scss/global.scss:296:12: Unknown word
You tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser

Error: /Users/btaylor/work/angular-apps/mdsl-authoring/assets/scss/mdsl-composer/mdsl-composer-variables.scss:103:1: Unknown word
You tried to parse SCSS with the …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

35
推荐指数
4
解决办法
8795
查看次数

可注入的“PlatformLocation”需要使用JIT编译器进行编译,但“@angular/compiler”不可用

我的 Angular 应用程序通过 Node 16.13.0 提供服务。更新到 Angular 13 后,我收到以下错误:

\n
\n

可注入 [类 PlatformLocation] 的 JIT 编译失败\nfile:///Users/btaylor/work/angular-apps/dz-outages-ui/node_modules/@angular/core/fesm2015/core.mjs:4058\n抛出新错误(消息);\n^

\n
\n
\n

错误:可注入的“PlatformLocation”需要使用 JIT 编译器进行编译,但“@angular/compiler”不可用。

\n
\n
\n

可注入程序是已部分编译的库的一部分。\n但是,Angular 链接器尚未处理该库,因此 JIT 编译用作后备。

\n
\n
\n

理想情况下,使用 Angular 链接器处理该库以进行完全 AOT 编译。\n或者,应使用 \'@angular/platform-b​​rowser-dynamic\' 或 \'@angular/platform-server\ 通过引导加载 JIT 编译器',\也不在引导之前手动为编译器提供 \'import "@angular/compiler";\'。\nat getCompilerFacade (file:///Users/btaylor/work/angular-apps/dz-outages-ui/node_modules /@angular/core/fesm2015/core.mjs:4058:15)\nat 模块。\xc9\xb5\xc9\xb5ngDeclareFactory (文件:///Users/btaylor/work/angular-apps/dz-outages-ui/ node_modules/@angular/core/fesm2015/core.mjs:32999:22)\nat 文件:///Users/btaylor/work/angular-apps/dz-outages-ui/node_modules/@angular/common/fesm2015/common .mjs:90:28\nat ModuleJob.run (节点:internal/modules/esm/module_job:185:25)\nat 异步 Promise.all (索引 0)\nat 异步 ESMLoader.import (节点:internal/modules/esm /loader:281:24)\nat 异步 loadESM (节点:internal/process/esm_loader:88:5)\nat 异步handleMainPromise (节点:internal/modules/run_main:65:12)

\n
\n

我尝试了多种解决方案,例如:Angular JIT 编译失败:'@angular/compiler' 未加载

\n

目前,我"type": "module" …

node.js typescript angular

27
推荐指数
2
解决办法
2万
查看次数

如何在Angular 2中访问ngrx效果中的参数?

我有一个http服务调用,在调度时需要两个参数:

@Injectable()
export class InvoiceService {
  . . .

  getInvoice(invoiceNumber: string, zipCode: string): Observable<Invoice> {
    . . .
  }
}
Run Code Online (Sandbox Code Playgroud)

我如何随后将这两个参数传递给this.invoiceService.getInvoice()我的效果?

@Injectable()
export class InvoiceEffects {
  @Effect()
  getInvoice = this.actions
    .ofType(InvoiceActions.GET_INVOICE)
    .switchMap(() => this.invoiceService.getInvoice())  // need params here
    .map(invoice => {
      return this.invoiceActions.getInvoiceResult(invoice);
    })
}
Run Code Online (Sandbox Code Playgroud)

ngrx angular

14
推荐指数
2
解决办法
1万
查看次数

使用 Supertest 时 request.cookies 未定义

我通过 NestJS API 中的 HTTP-Only cookie 传递身份验证令牌。

因此,在为我的 Auth 端点编写一些 E2E 测试时,我遇到了 cookie 不在我期望的位置的问题。

这是我精简的测试代码:

describe('auth/logout', () => {
  it('should log out a user', async (done) => {
    // ... code to create user account

    const loginResponse: Response = await request(app.getHttpServer())
                                              .post('/auth/login')
                                              .send({ username: newUser.email, password });

    // get cookie manually from response.headers['set-cookie']
    const cookie = getCookieFromHeaders(loginResponse);

    // Log out the new user
    const logoutResponse: Response = await request(app.getHttpServer())
                                            .get('/auth/logout')
                                            .set('Cookie', [cookie]);

  });
});
Run Code Online (Sandbox Code Playgroud)

在我的 JWT 策略中,我使用自定义 cookie 解析器。我遇到的问题是request.cookies …

cookies supertest nestjs

13
推荐指数
2
解决办法
1万
查看次数

ngrx状态未定义

我正在尝试将我的ngrx状态封装在共享服务类中,以从我的组件中抽象出实现细节.

在app.module.ts中注册的示例服务类 providers

@Injectable()
export class PatientService {

  state: Observable<PatientState>;

  constructor(
    private store: Store<AppState>,
  ) {
    this.state = store.select<PatientState>('patients');
  }

}
Run Code Online (Sandbox Code Playgroud)

我已经验证了我的操作,reducer和effect正在按预期工作,但是,当我订阅组件中的服务状态时,它返回undefined.

使用共享服务的示例组件订阅:

@Component({
  ...
})
export class DashboardComponent implements OnInit {

  constructor(
    private patientService: PatientService,
  ) {}

  ngOnInit(): void {
    // dispatches action to load patient from API
    this.patientService.loadPatient();

    this.patientService.state.subscribe(patientState => {
        console.log('patientState', patientState);
        // Does not work. Logs undefined.
    });
  }

}
Run Code Online (Sandbox Code Playgroud)

如果我直接订阅商店,它会按预期工作.

例:

@Component({
  ...
})
export class DashboardComponent implements OnInit {

  constructor(
    private patientActions: …
Run Code Online (Sandbox Code Playgroud)

ngrx angular

12
推荐指数
2
解决办法
5331
查看次数

是否可以使用插值字符串引用变量?

我有一个类别列表,我想从中设置背景颜色.我想将背景颜色的值保留为变量.是否可以通过字符串插值引用变量?Sass正在使用此代码抛出"无效CSS"错误:

/* Category Colors */
$family_wellness_color: #c1d72e;
$lifestyle_color: #f4eb97;
$food_color: #f78f1e;
...

/* Categories */
@each $cat in family_wellness, lifestyle, food
{
    .#{$cat}
    {
        .swatch, .bar
        {
            background-color: $#{$cat}_color;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

可能?我真的很感激一些建议!

sass

11
推荐指数
1
解决办法
4540
查看次数

如何修复“ TypeError:fsevents不是构造函数”的反应错误

在使用npm启动注视React应用时,发生此错误...

我尝试了以下事情:

  1. 删除node_module软件包并重新安装

  2. 使用yarn代替npm

3.使用npm更新fsevent库

仍然出现此错误

注意:如果我们创建react app,则新的/新的纱线启动将起作用,但是我们关闭终端并使用以下相同的内容重新启动,发生错误

/Users/nannam/test-app-2/node_modules/chokidar/lib/fsevents-handler.js:28
Run Code Online (Sandbox Code Playgroud)

return(new fsevents(path))。on('fsevent',callback).start(); ^

TypeError:fsevents不是setFSEventsListener(/ Users / nannam / test-app-2)上createFSEventsInstance(/Users/nannam/test-app-2/node_modules/chokidar/lib/fsevents-handler.js:28:11)的构造函数/node_modules/chokidar/lib/fsevents-handler.js:82:16)在FSWatcher.FsEventsHandler._watchWithFsEvents(/Users/nannam/test-app-2/node_modules/chokidar/lib/fsevents-handler.js:252:16 )在FSWatcher。(/Users/nannam/test-app-2/node_modules/chokidar/lib/fsevents-handler.js:386:25)在process._tickCallback(internal / process / next_tick)处于LOOP(fs.js:1565:14) js:61:11)错误命令失败,退出代码为1。info 访问 https://yarnpkg.com/en/docs/cli/run以获得有关此命令的文档。

javascript node.js reactjs

9
推荐指数
6
解决办法
8826
查看次数

在 RxJS 中重用可管道运算符

我在 Angular 组件中有两个主题,它们利用同一组可管道运算符为两个不同的表单字段提供预输入搜索查找。例子:

this.codeSearchResults$ = this.codeInput$
                               .pipe(
                                 untilDestroyed(this),
                                 distinctUntilChanged(),
                                 debounceTime(250),
                                 filter(value => value !== null),
                                 switchMap((value: string) => {
                                   const params: IUMLSConceptSearchParams = {
                                     ...TERMINOLOGY_SEARCH_PARAMS,
                                     sabs: this.sabs,
                                     term: value
                                   };

                                   return this.terminologyService.umlsConceptSearch(params);
                                 }),
                               );
Run Code Online (Sandbox Code Playgroud)

管道的定义似乎它将接受任意数量的函数,但是通过扩展提供函数

this.codeSearchResults$ = this.codeInput$.pipe(...operators);
Run Code Online (Sandbox Code Playgroud)

没有按预期工作。我如何为两个主题提供单一的函数输入源以保持我的代码干燥?

编辑

根据 Dan Kreiger 的回答中的选项#2,我的最终代码如下:

const operations = (context) => pipe(
      untilDestroyed(context),
      distinctUntilChanged(),
      debounceTime(250),
      filter(value => value !== null),
      switchMap(value => {
        const term: string = value as unknown as string;
        const params: IUMLSConceptSearchParams = {
          ...TERMINOLOGY_SEARCH_PARAMS,
          sabs: context.sabs,
          term, …
Run Code Online (Sandbox Code Playgroud)

rxjs

8
推荐指数
1
解决办法
1204
查看次数

在django中缓存匿名用户

我将如何为匿名用户缓存页面,但是为Django 1.6中的授权用户呈现这些页面?曾经有一个CACHE_MIDDLEWARE_ANONYMOUS_ONLY标志听起来很完美,但已被删除.

我问,因为每个页面都有一个菜单栏,显示登录用户的名字和他/她的个人资料的链接.

这样做的正确方法是什么?必须是一个常见的问题,但我没有找到正确的方式来浏览Django文档.

django caching django-templates django-cache anonymous-users

7
推荐指数
1
解决办法
654
查看次数

捕获<ng-content>中的组件发出的事件?

我有一个用于<ng-content>转换内容的自定义模态组件:

@Component({
  selector: 'modal-container',
  template: `
    <div [class]="css">
      <div [attr.id]="id" class="reveal" (open)="openModal()">
        <ng-content></ng-content>
      </div>
    </div>
  `
})
export class ModalContainerComponent {
    . . .
}
Run Code Online (Sandbox Code Playgroud)

<ng-content>我的内容中有一个发出open事件的组件:

@Component({
  selector: 'login-modal',
  template: `
    <modal-container [id]="'login-modal'">
      <section>...</section>
    </modal-container>
  `,
})
export class LoginModalComponent implements OnInit {

    @Output()
    open = new EventEmitter();

    ngOnInit(): void {
        // Here I am checking an ngrx store with code that is not included
        if (state.openLoginModal) {
          this.open.emit();
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

然而,ModalContainerComponent …

events angular

7
推荐指数
2
解决办法
8283
查看次数