多部分表单数据文件上传抛出错误body should be object。我正在使用ajv插件,但仍然遇到同样的问题。下面是我的代码供参考。
应用程序.js
const fastify = require('fastify')({
logger: true
});
const Ajv = require('ajv');
const ajv = new Ajv({
useDefaults: true,
coerceTypes: true,
$data: true,
extendRefs: true
});
ajv.addKeyword("isFileType", {
compile: (schema, parent, it) => {
parent.type = "file";
delete parent.isFileType;
return () => true;
},
});
fastify.setSchemaCompiler((schema) => ajv.compile(schema));
Run Code Online (Sandbox Code Playgroud)
路线.js
schema: {
tags: [{
name: 'Category'
}],
description: 'Post category data',
consumes: ['multipart/form-data'],
body: {
type: 'object',
isFileType: true,
properties: {
name: { …Run Code Online (Sandbox Code Playgroud) 这是我的 HTML 分页标签
<pagination class="pagination-sm" [(ngModel)]="page" [totalItems]="length" [itemsPerPage]="itemsPerPage" [maxSize]="maxSize" [boundaryLinks]="true" [rotate]="false" (pageChanged)="changePage($event)" (numPages)="numPages = $event"></pagination>
Run Code Online (Sandbox Code Playgroud)
和我的模型文件
import { Injectable } from '@angular/core';
import { NgbPaginationConfig} from '@ng-bootstrap/ng-bootstrap';
@Injectable()
export class PaginationConfig {
constructor(private config: NgbPaginationConfig) {
config.boundaryLinks = true;
config.maxSize = 5;
config.pageSize = 20;
config.size = 'sm';
}
}
Run Code Online (Sandbox Code Playgroud)
GitHub 包我在使用 @ng-bootstrap/ng-bootstrap 时出现以下错误
Unhandled Promise rejection: Template parse errors:
Can't bind to 'itemsPerPage' since it isn't a known property of 'pagination'. ("
</tbody>
</table>
<pagination class="pagination-sm" [(ngModel)]="page" [ERROR ->][itemsPerPage]="itemsPerPage" …Run Code Online (Sandbox Code Playgroud)