构造函数
function layer_custom() {
this.json = {
type: '',
title: null,
content: '',
area: '',
//skin:'layui-layer-rim',
//offset:
btnAlign: 'c',
closeBtn: null,
// shade: 0,
shade: [.1, '#000'],
shadeClose: false,
time: 0,
id: 'onlyOne',//这个id属性不想被覆盖
anim: 0,
resize: false,
yes: null,
no: null,
cancel: null,
btn1: null,
btn2: null,
btn3: null
}
}
实例方法
// 最多可传入3个自定义按钮名称
layer_custom.prototype.alertCustBtn = function(id, title, Arrbtn, content, area, fn, fn1, fn2, suc, destory) {
this.json.type = 1;
this.json.id = id;
this.json.btn = Arrbtn; //Arrbtn 是个数组
this.json.title = title;
this.json.closeBtn = 1;
this.json.content = content;
this.json.area = area;
this.json.btn1 = function(index, layero) {
fn && fn(index);
// layer.close(index);
};
this.json.btn2 = function(index) {
fn1 && fn1(index);
// layer.close(index);
};
this.json.btn3 = function(index) {
fn2 && fn2(index);
// layer.close(index);
};
this.json.success = function() {
suc && suc();
}
this.json.end = function() {
destory && destory();
}
layer.open(this.json);
};
调用代码
var did = 'dialog1';
//目前layer_custom上的id被覆盖成dialog1了,
//但是下次调用alertCustBtn时构造函数上的值就变成dialog1了,能不能让构造函数不记录最近一次的传值,而是在每次调用实例方法,我不覆盖属性,就用构造器上默认的属性值呢?
$layer.alertCustBtn(did, '案件详情', ['返回'], '', ['840px', '600px'], (index) => {
layer.close(index);
}, null, null, () => {
_tpl.layuiTplRender('caseDetailPanel_tpl', did, {});
});
目前layer_custom上的id被覆盖成dialog1了,
但是下次调用alertCustBtn时构造函数上的值就变成dialog1了,能不能让构造函数不记录最近一次的传值,而是在每次调用实例方法,我不覆盖属性,就用构造器上默认的属性值呢?
眼眸繁星
相关分类