Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

javascript - 未捕获的TypeError:undefined不是加载jquery-min.js的函数(Uncaught TypeError: undefined is not a function on loading jquery-min.js)

I'm building a normal webpage which requires me to load about five CSS files and ten Javascript files.

(我正在建立一个普通的网页,要求我加载大约五个CSS文件和十个Javascript文件。)

  • When loading them separately in the HTML page, my webpage loads fine.

    (在HTML页面中单独加载它们时,我的网页加载正常。)

  • Now for production, I concatenated all the Javascript into a single file, in the order needed, and all the CSS into another file.

    (现在进行制作,我将所有Javascript连接到一个文件中,按所需顺序连接,将所有CSS连接到另一个文件中。)

    But when I try to run the web page with the concatenated files it throws an error saying:

    (但是,当我尝试使用连接文件运行网页时,它会抛出错误说:)

    Uncaught TypeError: undefined is not a function

On the line where jquery.min.js is being loaded in the concatenated Javascript file.

(在连接的Javascript文件中加载jquery.min.js的行。)

What can I do to mitigate this?

(我该怎么做才能缓解这种情况?)

I want to concatenate all files and minify them for production.

(我想连接所有文件并缩小它们以进行生产。)

Please help.

(请帮忙。)


EDIT: I merged the Javascript and CSS in the order they were when they were being loaded individually and were working fine.

(编辑:我按照他们单独加载时的顺序合并了Javascript和CSS,并且工作正常。)

  ask by ghostCoder translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Assuming this problem still has not be resolved, a lot of individual files don't end their code with a semicolon.

(假设此问题仍未解决,许多单个文件不会以分号结束其代码。)

Most jQuery scripts end with (jQuery) and you need to have (jQuery);

(大多数jQuery脚本以(jQuery)结尾,你需要(jQuery);)

.

(。)

As separate files the script will load just fine but as one individual file you need the semicolons.

(作为单独的文件,脚本将加载正常,但作为一个单独的文件,您需要分号。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...