[英]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.