在最近的 Angular 7 项目中,我有一个组件(在文件中定义file-list.component.ts),其中有一个mat-paginator(来自 Angular 材料组件库的组件)。当我想更改 的背景颜色时mat-paginator,我首先尝试将
.mat-paginator-container {
background-color: yellow;
}
Run Code Online (Sandbox Code Playgroud)
在film-list.component.scss(与此组件关联的样式表)中,分页器的背景颜色没有改变。当我把app.component.scss它放进去时,它也不起作用。但是当我把它放在 中时src/styles.css,背景颜色正确地改变了。
所以我的问题是:
src/styles.scss,app.component.scss和film-list.component.scss?body这些样式表文件中使用的选择器有什么影响?我有后端 API,它接受带有图像表单数据的 POST 方法,如下所示,

当使用上面的 Postman 时,一切正常。但是当我想在 Angular 中执行此操作时,它不起作用。
<!-- html template file -->
<input type="file" (change)="handleInputEvent($event)"/>
Run Code Online (Sandbox Code Playgroud)
import {Component, OnInit} from '@angular/core';
import {MyDearFishService} from '../../my-dear-fish.service';
@Component({
selector: 'app-upload',
templateUrl: './upload.component.html',
styleUrls: ['./upload.component.scss']
})
export class UploadComponent implements OnInit {
constructor(public service: MyDearFishService) {
}
ngOnInit() {
}
arrayOne(n: number): any[] {
return Array(n);
}
handleInputEvent($event) {
const image = $event.target.files[0];
this.service.recognizeFish(image);
}
}
Run Code Online (Sandbox Code Playgroud)
// My service file (using HttpClient):
const rootUrl = 'https://...../api';
public recognizeFish(image: File): Promise<any> {
return …Run Code Online (Sandbox Code Playgroud) static void ddict_debug(const char* fmt, ...) G_GNUC_PRINTF(1, 2);
Run Code Online (Sandbox Code Playgroud)
我在.c文件中发现了这个,我不明白这一行:是否只有一个函数声明或两个?
这段代码是什么意思?
我有以下c代码:
#include <stdio.h>
#include <stdlib.h>
void *func(int a) {
if (a==3) {
int a_int = 5;
int *ptr_int = &a_int;
return (void *)ptr_int;
}
else if (a==4) {
char a_char = 'b';
char *ptr_char = &a_char;
return (void *)ptr_char;
}
else {
fprintf(stderr, "return value is NULL");
return NULL;
}
}
int main (int argc, char *argv[]) {
int *ptr_int = (int *)func(3);
char *ptr_char = (char *)func(4);
fprintf(stdout, "int value = %d\n", *ptr_int);
fprintf(stdout, "char value = %c\n", *ptr_char); …Run Code Online (Sandbox Code Playgroud) 假设我有以下流:
...
import javafx.util.Pair;
...
Pair[] testPairs = {
new Pair<>("apple", "James"),
new Pair<>("banana", "John"),
new Pair<>("grapes", "Tom"),
new Pair<>("apple", "Jenkins"),
new Pair<>("banana", "Edward"),
new Pair<>("grapes", "Pierre")
};
Map<String, List<String>> result1 = Arrays.stream(testPairs)...;
Map<String, String> result2 = Arrays.stream(testPairs)...;
Run Code Online (Sandbox Code Playgroud)
对于result1,我想按对的键进行分组并获取所有对应的名称。对于result2,我想按键分组并获取字符串列表中的任何一个(前一个结果)。
如何通过使用 java 8 stream api 来实现这一点?