小编Rav*_*eja的帖子

Fastify 模式验证多部分/表单数据(主体应该是对象)

多部分表单数据文件上传抛出错误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)

node.js fastify

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

无法绑定到“totalItems”,因为它不是“分页”的已知属性

这是我的 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)

angular

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

标签 统计

angular ×1

fastify ×1

node.js ×1