简体   繁体   English

关键依赖项:依赖项的请求是jQuery Form Validator插件上的一个表达式

[英]Critical dependency: the request of a dependency is an expression on jQuery Form Validator plugin

I have problem on loading security module from jQuery Form Validator plugin : 我在从jQuery Form Validator插件加载安全模块时遇到问题:

$.validate({
    modules : 'security'
});

I'm using webpack and Laravel-mix for boundeling my files and I got this error: 我正在使用webpack和Laravel-mix来限制文件的大小,但出现此错误:

Critical dependency: the request of a dependency is an expression. 关键依赖项:依赖项的请求是一个表达式。

Every thing is fine and even the validations is working but this warning might break some other files to be bundled. 一切都很好,甚至验证都可以,但是此警告可能会破坏其他要捆绑的文件。

I found that this is problem with loadModules function . 我发现这是loadModules函数的问题。

Here is how you can fix it: Instead of loading the whole security.js or other modules you should grape your validation from that module instead of loading it all and then add it to your main js file. 解决方法如下:与其加载整个security.js或其他模块,不如从该模块获取验证,而不是全部加载,然后将其添加到主js文件中。 Here I need confirmation from security.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.

相关问题 关键依赖:一个依赖的请求是一个表达式——react-universal-component - Critical dependency: the request of a dependency is an expression -- react-universal-component Webpack编译不正确(严重依赖性:依赖性的请求是一个表达式) - Webpack not properly compiling (Critical dependency: the request of a dependency is an expression) 关键依赖:依赖的请求是使用延迟加载时的表达式 - Critical dependency: the request of a dependency is an expression while using lazy loading 关键依赖:依赖的请求是一个表达式(Angular CLI 警告) - Critical dependency: the request of a dependency is an expression (Angular CLI Warning) 如何解决我的npm包的“关键依赖关系:依赖关系的请求是一个表达式”错误? - How to resolve “Critical dependency: the request of a dependency is an expression” error for my npm package? ./node_modules/express/lib/view.js 中的 Webpack 警告关键依赖:依赖的请求是一个表达式 - Webpack WARNING in ./node_modules/express/lib/view.js Critical dependency: the request of a dependency is an expression jQuery验证依赖项表达式 - jQuery Validate dependency-expression 在 webpack 管理 jQuery 插件依赖 - Managing jQuery plugin dependency in webpack FabricJs,Webpack无法编译-严重依赖 - FabricJs, Webpack not compiling - Critical dependency 需要Jquery Validation Plugin方法(dependency-expression)使用ok但回调不起作用 - Jquery Validation Plugin Method required( dependency-expression ) use ok but callback not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM