[英]Critical dependency: the request of a dependency is an expression -- react-universal-component
[英]Critical dependency: the request of a dependency is an expression on jQuery Form Validator plugin
我在从jQuery Form Validator插件加载安全模块时遇到问题:
$.validate({
modules : 'security'
});
我正在使用webpack和Laravel-mix来限制文件的大小,但出现此错误:
关键依赖项:依赖项的请求是一个表达式。
一切都很好,甚至验证都可以,但是此警告可能会破坏其他要捆绑的文件。
我发现这是loadModules
函数的问题。
解决方法如下:与其加载整个security.js
或其他模块,不如从该模块获取验证,而不是全部加载,然后将其添加到主js文件中。 在这里,我需要来自security.js的确认:
import './form-validation';
$.formUtils.addValidator({
name: 'confirmation',
validatorFunction: function (value, $el, config, language, $form) {
var password,
passwordInputName = $el.valAttr('confirm') ||
($el.attr('name') + '_confirmation'),
$passwordInput = $form.find('[name="' + passwordInputName + '"]');
if (!$passwordInput.length) {
$.formUtils.warn('Password confirmation validator: could not find an input ' +
'with name "' + passwordInputName + '"', true);
return false;
}
password = $passwordInput.val();
if (config.validateOnBlur && !$passwordInput[0].hasValidationCallback) {
$passwordInput[0].hasValidationCallback = true;
var keyUpCallback = function () {
$el.validate();
};
$passwordInput.on('keyup', keyUpCallback);
$form.one('formValidationSetup', function () {
$passwordInput[0].hasValidationCallback = false;
$passwordInput.off('keyup', keyUpCallback);
});
}
return value === password;
},
errorMessage: '',
errorMessageKey: 'notConfirmed'
});
$.validate({
form: '#signup-header',
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.