Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript &引用;未捕获错误:关键字if已定义";使用ajv关键字_Javascript_Ajv - Fatal编程技术网

Javascript &引用;未捕获错误:关键字if已定义";使用ajv关键字

Javascript &引用;未捕获错误:关键字if已定义";使用ajv关键字,javascript,ajv,Javascript,Ajv,我试图使用来自的if/then/else关键字创建条件验证,但是在浏览器控制台中出现以下错误:“未捕获错误:关键字if已定义” 我做错了什么 import * as ajvErrors from 'ajv-errors'; import * as ajvKeywords from 'ajv-keywords'; const ajv = new Ajv({ allErrors: true, jsonPointers: true }); ajvErrors(ajv); ajvKeywords(aj

我试图使用来自的if/then/else关键字创建条件验证,但是在浏览器控制台中出现以下错误:“未捕获错误:关键字if已定义”

我做错了什么

import * as ajvErrors from 'ajv-errors';
import * as ajvKeywords from 'ajv-keywords';

const ajv = new Ajv({ allErrors: true, jsonPointers: true });
ajvErrors(ajv);
ajvKeywords(ajv);

const schema = {
  if: {
    properties: {
      fundraiser: { type: 'string' }
    }
  },
  then: {
    required: ['title'],
  }
}

如果您正在使用ajv测试版,它已经包括If/then/else,您不需要ajv关键字(或者您也需要使用测试版)