我想发送一个csv文件代替graphql查询。我正在使用Apollo服务器,Apollo客户端和Reactjs。(将csv文件从服务器发送到客户端)
谁能给我一个想法,我该如何实施?
在 Ng bootstrap carousel 组件中,如何在图像/幻灯片之间进行淡入/淡出等过渡?
我想基于接口创建类,但它看起来链接它不尊重 readonly 修饰符。
下面的代码在没有编译器错误的情况下工作:
interface I {
readonly a: string
}
class C implements I{
a= ""
}
const D = new C
D.a = "something"
Run Code Online (Sandbox Code Playgroud)
为了使属性“a”真正只读,我也应该在类定义中将其设为只读!那么接口定义中 readonly 修饰符的用例是什么?
换句话说,我如何通过实现使用正确修饰符创建它的接口来确保何时创建一个类?
我在父组件(主组件)中有一个项目列表,当用户单击其中一个项目时,在同一页面上的另一个组件(子/详细信息)中,它会显示所选项目的详细信息。我在子组件中有一个删除按钮,可以从数据库中删除所选项目。
我的问题是如何在删除子组件中的项目后更新父组件中的项目列表?
父组件:
export class ProjectListComponent implements OnInit {
projects : Project[];
selectedProject: Project;
constructor(private _projectService: ProjectService) { }
ngOnInit() {
this.projects = [];
this.fetchListOfProjects();
}
fetchListOfProjects(){
this._projectService.getProject()
.subscribe(projects => {
this.projects = projects;
})
}
onSelect(project: Project): void {
this.selectedProject = project;
}
}
Run Code Online (Sandbox Code Playgroud)
子组件:
export class ProjectItemComponent implements OnInit {
@Input() project: Project;
constructor(private _projectService:ProjectService) { }
ngOnInit() { }
onDelete(id:any){
if(confirm("Are you sure to delete the project?")) {
this._projectService.deleteProject(id)
.subscribe(result =>{
if(result.status == 204){
console.log('removed');
};
}); …Run Code Online (Sandbox Code Playgroud) Graphql 中的架构和文档有什么区别?
架构是这样的:
type Query {
fo: String
}
Run Code Online (Sandbox Code Playgroud)
但文件是这样的:
query SomeQuery {
foo {
bar
}
}
Run Code Online (Sandbox Code Playgroud)
规范真的很混乱https://graphql.github.io/graphql-spec/June2018/#sec-Language.Document
我总是使用模式,但对于 graphql-code-generator 中的客户端类型生成,它需要文档文件。https://graphql-code-generator.com/docs/getting-started/documents-field
我在表单中输入了一个简单的表单输入,但 required 对我不起作用,并且提交了空输入。这是我的代码:
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="test"
required
name="test">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的表单标签:
<form class="form-horizontal" (ngSubmit)="onSubmit()">
Run Code Online (Sandbox Code Playgroud)
这是我的提交按钮标签:
<button type="submit" class="btn btn-default">Save</button>
Run Code Online (Sandbox Code Playgroud) 如何在选定的事件中获取originalObject?
例如,在这段代码中,我想使用值字段,但搜索颜色!
protected searchData = [
{ color: 'red', value: '#f00' },
{ color: 'green', value: '#0f0' },
{ color: 'blue', value: '#00f' },
{ color: 'cyan', value: '#0ff' },
{ color: 'magenta', value: '#f0f' },
{ color: 'yellow', value: '#ff0' },
{ color: 'black', value: '#0' }
];
constructor(private completerService: CompleterService) {
this.dataService = completerService.local(this.searchData, 'color','color');
}
Run Code Online (Sandbox Code Playgroud)
这是我的模板:
<ng2-completer [(ngModel)]="searchStr" [datasource]="dataService"
[minSearchLength]="0">
Run Code Online (Sandbox Code Playgroud)
谢谢.
如果 InputNumber 组件失去焦点,我想使用 blur 方法运行一个函数,但我不知道如何使用它。
<InputNumber
value={value}
onChange={this.handleChange}
onKeyDown={this.onKeyHandler}
size="small"
min={0}
step={0.5}
/>
Run Code Online (Sandbox Code Playgroud) angular ×3
graphql ×2
animation ×1
antd ×1
class ×1
forms ×1
interface ×1
ng-bootstrap ×1
parent ×1
react-apollo ×1
readonly ×1
transition ×1
typescript ×1