如何在单独的页面反应中包含表单验证.js语义 UI



在语义 UI 文档中,它指出您可以使用完整的验证设置来验证文件。我创建了一个单独的文件,用于处理验证。

import React from 'react';
import $ from 'jquery';
$(document).ready(function() {

$('.booking')
.form({
fields: {
fromCountry: {
identifier: "fromCountry",
rules: [
{
type: "empty",
prompt: "Please enter your name"
}
]
}
}
})

}(;

我已将此验证文件导入到需要验证的其他 react js 文件中。但是,它指出形式不是一种函数。表单属于哪个库?

您可以 https://react.semantic-ui.com/collections/form/#types-form 结帐。

您也可以使用上面的代码,但首先您必须在执行上述代码之前检查脚本是否已加载,并且您必须将代码移动到 componentDidMount 生命周期方法。

最新更新