方法一:(最简单也是最笨的方法)
window.a = function(){}
window.b = function(){}
window.c = function(){}
方法二:(利用jq的extend方法)
window.c = function(){}$.extend(window,{
a:function(){},
b:function(){},
c:function(){},
})
方法三:(利用js)
(() => {
var defining = {
a: function() { },
b: function() { },
c: function() { }
};
Object.keys(defining).forEach(key => {
window[key] = defining[key];
});
})();
方法四:(window 下的对象是变量的时候)
window[变量]=function(){}