如何在 requirejs 中使用 jquery.validate?

How to use jquery.validate with requirejs?

require.config({  
    paths:{  
        jquery:"lib/jquery-1.12.3.min",  
        bootstrap:"lib/bootstrap.min",  
        validate:"lib/jquery.validate.min"  
    },  
    shim:{  
        bootstrap:['jquery'],  
        validate:['jquery']    
    }  
});      


require(['jquery','validate'],function(){  
    alert("hope it works");  
});  

告警方式无效
但是,如果我在

中删除 'validate'
require(['jquery','validate'],function(){  
     alert("hope it works");  
});  

就像这样:

require(['jquery'],function(){  
     alert("hope it works");  
});  

然后,警报方法起作用了。
这向我表明验证库和 RequireJs 一起存在问题。
我确定我做错了一些微不足道的错误。
我很感激你的帮助。谢谢

它按预期工作。

正在工作 fiddle - https://jsfiddle.net/p15nn7jb/

require.config({  
    paths:{  
        jquery:"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery",  
        bootstrap:"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min",  
        validate:"https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.min"  
    },  
    shim:{  
        bootstrap:['jquery'],  
        validate:['jquery']    
    }  
});      


require(['jquery','validate'],function(){  
    alert("hope it works");  
});

另请参阅下面的 link,它使用 jquery 验证和 require js

https://jqueryvalidation.org/files/demo/requirejs/index.html

有类似的错误 只有我想使用本地化消息 不能让它只在本地使用 cdn

    require.config({  
paths:{  
    jquery:"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery",    
    validate:"https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.15.0/jquery.validate.min",  
    messages_he:"https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.18.0/localization/messages_he.min"  
},  
shim:{  
    bootstrap:['jquery'],  
    validate:['jquery']    
    }  
});      


require(['jquery','validate'],function(){  
    $.validator.setDefaults({
        submitHandler: function () {
            console.log("submitted!");
        }
    });
    $("form").validate();
}); 

但是这个本地工作正常

require.config({  
paths:{  
    jquery:"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery",    
    validate:"libs/jquery-validate/1.15.0/jquery.validate.min",  
    messages_he:"libs/jquery-validate/1.18.0/localization/messages_he.min"  
},  
shim:{  
    bootstrap:['jquery'],  
    validate:['jquery']    
    }  
});      

require(['jquery', paths.jqueryval, paths.messages_he],function(){  
    $.validator.setDefaults({
        submitHandler: function () {
            console.log("submitted!");
        }
    });
    $("form").validate();
});