報錯信息
jquery.validate.extend.js:3 Uncaught TypeError: Cannot read property 'setDefaults' of undefined at HTMLDocument.<anonymous> (VM445 jquery.validate.extend.js:3) at j (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at Function.ready (jquery.min.js:2) at HTMLDocument.I (jquery.min.js:2)
原因
js文件的順序錯了,代碼示例如下:
<script src="/js/jquery.min.js"></script> <script src="/ajax/libs/validate/jquery.validate.min.js"></script> <script src="/js/jquery.min.js"></script>
有效jquery.min.js加載是第二個。造成jquery.validate.min.js先加載,然后才是jquery.min.js;而jquery.validate.min.js又是基於jquery.min.js。
解決
將第二個jquery.min.js引入去掉。