我将 js 代码复制粘贴到谷歌编译器中,当我将其复制回我的应用程序时,它不起作用。我意识到我的代码需要jquery,所以我将jquery代码和我的代码复制到google编译器中,希望它能轻松解决问题,但它也不起作用。
在chrome下,代码有bug就行$(document).K(function () {
这是文档准备功能。错误是Uncaught TypeError: Object [object Object] has no method 'K'
我需要做什么才能使其(暂时)发挥作用?
感谢您的建议。
Use @externs_url
在 Google 的 Closure 编译器中“导入”符号:
// @externs_url https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jquery-1.9.js
我建议使用中定义的外部之一贡献/外部人员 https://github.com/google/closure-compiler/tree/master/contrib/externs,仅包含所有方法的名称。
Example
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @externs_url https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jquery-1.9.js
// ==/ClosureCompiler==
$(document).ready(function(){alert(0);}); // Input
Output:
$(document).ready(function(){alert(0)});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)