layui模块大多都是类似的处理方法,这里只是拿来举例:
修改组件大约23行-32行中间添加一行,e.data=e.savedata && e.savedata(e.data) || e.data;
tree.prototype.template = function(e) {
var t = this,
level = [],
tbody = '',
is_table = o('table' + e.elem).length || !(e.is_click_icon = true),
checkbox = e.is_checkbox ? '<div class="layui-unselect layui-form-checkbox cbx" lay-skin="primary"><i class="layui-icon layui-icon-ok"></i></div>' : '',
checked = checkbox ? checkbox.replace('cbx', 'cbx layui-form-checked') : '',
thead = checkbox && '<th style="width:28px;">' + (o.inArray(e.top_value, e.checked.data) > -1 ? checked : checkbox) + '</th>';
o.each(t.data(e, e.data), function(idx, item) {
原有的
tree.prototype.template = function(e) {
var t = this,
level = [],
tbody = '',
is_table = o('table' + e.elem).length || !(e.is_click_icon = true),
checkbox = e.is_checkbox ? '<div class="layui-unselect layui-form-checkbox cbx" lay-skin="primary"><i class="layui-icon layui-icon-ok"></i></div>' : '',
checked = checkbox ? checkbox.replace('cbx', 'cbx layui-form-checked') : '',
thead = checkbox && '<th style="width:28px;">' + (o.inArray(e.top_value, e.checked.data) > -1 ? checked : checkbox) + '</th>';
e.data=e.savedata && e.savedata(e.data) || e.data;
o.each(t.data(e, e.data), function(idx, item) {
修改后