小编net*_*djw的帖子

如果我使用公钥进行身份验证,为什么要询问 VS Code 远程 SSH 插件的密码?

我刚刚开始使用远程 - SSH (ms-vscode-remote.remote-ssh) 插件。我把这段代码放入settings.json

    "remote.SSH.remotePlatform": {
        "myserver": "linux"
    }
Run Code Online (Sandbox Code Playgroud)

在文件中config

Host myhost
  HostName myhost
  User root
  IdentityFile ~/.ssh/id_rsa.pub
Run Code Online (Sandbox Code Playgroud)

正如文档所说,我期望 - 就像在 PuTTY 中一样 - 插件只需登录并完成,但它仍然要求登录密码。

有没有我错过的设置?或者是否有任何我必须应用的设置以避免询问密码?

visual-studio-code vscode-remote

6
推荐指数
1
解决办法
8059
查看次数

当我尝试在 Angular 10 中使用库中的服务时,“无法解析服务的所有参数:(?)”

在我的图书馆中,我有一个带有以下代码的服务:

import { Inject, Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { DataInjectorModule } from '../../data-injector.module';

// @dynamic
@Injectable()
export class RemoteDataService<T> {
  @Inject('env') private environment: any = {};
  public type: new () => T;
  
  constructor(
    model: T,
  ) {
    this.http = DataInjectorModule.InjectorInstance.get(HttpClient);
  }

  // ...
}
Run Code Online (Sandbox Code Playgroud)

(现有原因data-injector.module只是避免循环依赖):

import { NgModule, Injector } from '@angular/core';

// @dynamic
@NgModule({
  declarations: [],
  imports: [],
  providers: [],
  exports: [],
})
export class DataInjectorModule {
  static InjectorInstance: Injector; …
Run Code Online (Sandbox Code Playgroud)

injectable angular angular10

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

如何在 GitHub 操作中实现可访问性 linting?

我想使用基于 WCAG 2.1 的可访问性 linting 升级我们的 GitHub 工作流程。如果可能的话,我也想将级别定义为AA.

我不想在网站上运行完整的测试,只想对拉取请求进行快速检查。整个站点测试将是下一步,但现在我只想专注于拉取请求。

我基于此检查了pa11y和几个存储库,但正如我所见,此解决方案只能测试一个工作网站,而不能测试拉取请求。

有什么可行的解决方案吗?

accessibility github wcag linter github-actions

6
推荐指数
0
解决办法
152
查看次数

CSS 定位到中心加上 x 像素

有什么方法可以只CSS用于定位 center plus x pixel adiv吗?

我现在有这个 CSS 代码:

#mydiv {
    display: block;
    width: 200px;
    margin: 200px auto;
}
Run Code Online (Sandbox Code Playgroud)

我想将此 div 定位到中心 + 300px 到右侧。可以只使用 CSS 吗?

(我知道这是一种使用 jQuery 的方法,但我只想使用 CSS。)

html css jquery

5
推荐指数
1
解决办法
1947
查看次数

如何在 Angular 8 中的抽象类和抽象类的实现中使用 @Component 装饰器?

我使用 Angular 8 并尝试使用抽象组件。我想在抽象类中定义 templateUrl 和 styleUrls,但在实现的类中定义选择器名称。像这样:

@Component({
  // selector isn't defined here
  templateUrl: './abstract-list.component.html',
  styleUrls: ['./abstract-list.component.scss']
})
export abstract class AbstractListComponent<T> implements OnInit {
  // ...
}
Run Code Online (Sandbox Code Playgroud)

而在幼儿班

@Component({
  selector: 'app-my-custom-list',
  // templateUrl & styleUrls is should be inherited
})
export class MyCustomListComponent extends AbstractListComponent<MyCustomListInterface> implements OnInit {
  // ...
}
Run Code Online (Sandbox Code Playgroud)

我尝试仅在这样的实现中使用装饰器,但我觉得这里需要一个更好的方法:

@Component({
  selector: 'app-my-custom-list',
  templateUrl: '../../abstract-list/abstract-list.component.html',
  styleUrls: ['../../abstract-list/abstract-list.component.scss']
})
Run Code Online (Sandbox Code Playgroud)

是否可以使用@Component类似这样的装饰器?或者对于这种用法有什么技巧或最佳实践吗?

typescript angular angular8

5
推荐指数
1
解决办法
4748
查看次数

如何避免 Angular 9 中复杂 RxJS 管道的内存泄漏?

我的 Angular + RxJS 应用程序中有一点复杂的管道结构:

远程数据.service.ts:

getAll(url): Observable<any[]> {
  return this.http.get(url, this.options)
    .pipe(map((result: any[]) => result));
}
Run Code Online (Sandbox Code Playgroud)

代理.服务.ts:

// localDataService use my LocalDataService
// remoteDataService use my RemoteDataService

getAll(model): Observable<any[]> {
  if (model.use_localstorage) {
    return this.localDataService.getAll(model)
      .pipe(map((result: any[]) => result));
  } else {
    return this.remoteDataService.getAll(model.url)
      .pipe(map((result: any[]) => result));
  }
}
Run Code Online (Sandbox Code Playgroud)

助手.service.ts:

getAll(model): Observable<any[]> {
  // do some general fancy things...
  return this.proxyService.getAll(model)
      .pipe(map((result: any) => result));
  }
}
Run Code Online (Sandbox Code Playgroud)

然后在我的组件中:

export class MyComponent {
  helperService = new HelperService(); …
Run Code Online (Sandbox Code Playgroud)

memory-leaks rxjs typescript angular

5
推荐指数
1
解决办法
6644
查看次数

如何获取 RxJS Subject 的先前值?

我的项目我需要将我的分页器的pageSize值(每页项目数)与以前的值进行比较,如果新值更高,那么我需要从存储中加载数据。但如果它不是更高,我不想做任何事情。

例如在这段代码中:

export class MyComponent {
  paginatorPageSize: BehaviorSubject<number> = new BehaviorSubject<number>(10);
  // ...

  savePageSettings() {
    this.pageService.save().pipe(
      map((result: any) => {
        // ...
      }),
      tap(() => this.anyCode.here()),
      switchMap((result: any) => {
        // ...
      }),
      switchMap(() => {
        const previousPageSize = ??? // <--- here how can I get the prevoius value of paginatorPageSize?

        if (previousPageSize >= this.paginatorPageSize.value) {
          return this.pageService.getAll();
        }

        return of(null)
      })
    ).subscribe();
  }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法获得 RxJS Subject / BehavioSubject 或任何类型的主题的先前发出的值?

rxjs typescript rxjs6

5
推荐指数
1
解决办法
4243
查看次数

Laravel Sail 正在关闭每个 sail 命令的旧 Sail 进程

我刚刚开始使用 Laravel Sail (v1.4.7),如果我运行以下命令:

sail up -d
Run Code Online (Sandbox Code Playgroud)

然后所有容器启动。

然后我尝试运行这个:

sail composer dump-autoload
Run Code Online (Sandbox Code Playgroud)

响应是:

projectname-               docker-              Exit 1
Shutting down old Sail processes...
Sail is not running.

You may Sail using the following commands: './vendor/bin/sail up' or './vendor/bin/sail up -d'
Run Code Online (Sandbox Code Playgroud)

我尝试过composer dump-autoload无帆运行,效果很好。但这不是在容器内运行(所以将来它可能会在不同的版本上运行)。

更新:

我在 WSL2、Ubuntu 20.04 中运行容器。

为什么此时要关闭容器?但实际上不只是这个命令发生关闭。每个sail ...命令的发生都是相同的。

任何想法?

laravel-8 laravel-sail

5
推荐指数
1
解决办法
3733
查看次数

如何修复:错误:同步和异步加载 Angular 结构

我刚刚将我的 Angular 6 项目升级到了 Angular 11。这个项目已经实现了 SSR,这是问题所在。

当我运行时,ng run myapp:server我收到此错误:

? Server application bundle generation complete.

Initial Chunk Files | Names         |    Size
main.js             | main          | 4.06 kB

                    | Initial Total | 4.06 kB

Build at: 2021-04-22T14:02:16.388Z - Hash: 2a6aaefe9d15b8a7dedc - Time: 4907ms

Error: Angular structure loaded both synchronously and asynchronously
Run Code Online (Sandbox Code Playgroud)

在我的angular.json我有这个代码:

? Server application bundle generation complete.

Initial Chunk Files | Names         |    Size
main.js             | main          | 4.06 kB

                    | Initial Total | …
Run Code Online (Sandbox Code Playgroud)

server-side-rendering angular

5
推荐指数
3
解决办法
4383
查看次数

Bootstrap 5 工具提示在 Angular 11 项目中不起作用

我尝试在 Angular 11 项目中使用 Bootstrap 5.0.2,代码如下:

索引.html

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Expires" content="0">
  <title>My Project</title>
  <base href="/">
  <meta http-equiv="content-language" content="en-US" />

  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</head>
<body>
  <app-root></app-root>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在组件中:

<a class="btn btn-primary"
  data-bs-toggle="tooltip"
  data-bs-html="true"
  data-bs-placement="top"
  [title]="myTitle | toHtmlEntity"
  [href]="myUrl">

  {{ myButtonLabel }}
</a>
Run Code Online (Sandbox Code Playgroud)

没有错误消息,但工具提示不起作用。当鼠标悬停在链接上时,标题字符串就会出现。

知道我错过了什么吗?

tooltip twitter-bootstrap angular bootstrap-5

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