Cannot read property 'setDefaults' of undefined


報錯信息

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引入去掉。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM