conmmon。js:
layui.define(['jquery'], function(exports){
var obj = {
ajax: function (url, type, dataType, data, callback) {
$.ajax({
url: url,
type: type,
dataType: dataType,
data: data,
success: callback
});
}
};
//输出接口
exports('common', obj);
});
public.js
$(function() {
layui.config({
base: 'js/global/' //自定义layui组件的目录
}).extend({ //设定组件别名
common: 'common',
});
})