Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sentsim committed Apr 6, 2021
1 parent b0646a2 commit 41a47c6
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 17 deletions.
4 changes: 2 additions & 2 deletions dist/layui.js

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion examples/all.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@

<script src="../dist/layui.js"></script>
<script>
console.log(layui.dropdown);

//(function(){
layui.use(function(){
var $ = layui.jquery
,layer = layui.layer
Expand All @@ -77,15 +80,18 @@
elem: 'demo1'
,count: 100 //总页数
});


console.log(lay('#footer').html());

//测试加载非内置模块
/*
layui.config({
base: 'extends/'
}).extend({
mod1: 'mod1'
,mod2: 'mod2'
}).use('mod1');
*/


//定义标题及数据源
Expand Down Expand Up @@ -150,7 +156,21 @@
});
}
});

});
//})();
</script>



<span class="layui-breadcrumb" lay-separator="-">
<a href="">首页</a>
<a href="">国际新闻</a>
<a href="">亚太地区</a>
<a><cite>正文</cite></a>
</span>

<div id="footer">© footer</div>

</body>
</html>
4 changes: 1 addition & 3 deletions examples/extends/mod2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

layui.define(function(exports){
console.log('mod2.js')

layer.alert(1)


exports('mod2', {
name: 'mod2'
})
Expand Down
2 changes: 2 additions & 0 deletions examples/layer.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@
}]
});
}

};

$('.demo').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
Expand Down
10 changes: 5 additions & 5 deletions src/layui.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@
deps = []
);

that.use(deps, callback);
that.use(deps, callback, null, 'define');
return that;
};

//使用特定模块
Layui.prototype.use = function(apps, callback, exports){
Layui.prototype.use = function(apps, callback, exports, from){
var that = this
,dir = config.dir = config.dir ? config.dir : getPath
,head = doc.getElementsByTagName('head')[0];
Expand Down Expand Up @@ -154,15 +154,15 @@
}());
}
}

//回调
function onCallback(){
exports.push(layui[item]);
apps.length > 1 ?
that.use(apps.slice(1), callback, exports)
that.use(apps.slice(1), callback, exports, from)
: ( typeof callback === 'function' && function(){
//保证文档加载完毕再执行回调
if(layui.jquery && typeof layui.jquery === 'function'){
if(layui.jquery && typeof layui.jquery === 'function' && from !== 'define'){
return layui.jquery(function(){
callback.apply(layui, exports);
});
Expand Down
5 changes: 4 additions & 1 deletion src/modules/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,10 @@ layui.define('jquery', function(exports){
Element.prototype.render = Element.prototype.init;

var element = new Element(), dom = $(document);
element.render();

$(function(){
element.render();
});

var TITLE = '.layui-tab-title li';
dom.on('click', TITLE, call.tabClick); //Tab切换
Expand Down
4 changes: 3 additions & 1 deletion src/modules/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,9 @@ layui.define('layer', function(exports){
var form = new Form()
,$dom = $(document), $win = $(window);

form.render();
$(function(){
form.render();
});

//表单reset重置渲染
$dom.on('reset', ELEM, function(){
Expand Down
13 changes: 9 additions & 4 deletions src/modules/lay.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,21 @@
});
};

//设置HTML内容
//设置或获取 HTML 内容
LAY.prototype.html = function(html){
return this.each(function(index, item){
var that = this;
return html === undefined ? function(){
if(that.length > 0) return that[0].innerHTML;
}() : this.each(function(index, item){
item.innerHTML = html;
});
};

//设置值
//设置或获取值
LAY.prototype.val = function(value){
return this.each(function(index, item){
return value === undefined ? function(){
if(that.length > 0) return that[0].value;
}() : this.each(function(index, item){
item.value = value;
});
};
Expand Down

0 comments on commit 41a47c6

Please sign in to comment.