Zepto相当于jQuery.getScript()是什么? [英] What's the Zepto equivalent of jQuery.getScript()?
本文介绍了Zepto相当于jQuery.getScript()是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Zepto与jQuery.getScript()等效吗?我需要同时使用这两个库动态加载JavaScript文件.
What's the Zepto equivalent of jQuery.getScript()? I need to dynamically load a JavaScript file with both libraries.
推荐答案
此作品已附加到zepto.js!
This works appended to zepto.js!
;(function ($) {
$.getScript = function(src, func) {
var script = document.createElement('script');
script.async = "async";
script.src = src;
if (func) {
script.onload = func;
}
document.getElementsByTagName("head")[0].appendChild( script );
}
})($)
这篇关于Zepto相当于jQuery.getScript()是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文