pull/859/head v2.6.3-2
贤心 4 years ago
parent b0646a2f11
commit 41a47c6300

4
dist/layui.js vendored

File diff suppressed because one or more lines are too long

@ -62,6 +62,9 @@ resize: none;">
<script src="../dist/layui.js"></script> <script src="../dist/layui.js"></script>
<script> <script>
console.log(layui.dropdown);
//(function(){
layui.use(function(){ layui.use(function(){
var $ = layui.jquery var $ = layui.jquery
,layer = layui.layer ,layer = layui.layer
@ -77,15 +80,18 @@ layui.use(function(){
elem: 'demo1' elem: 'demo1'
,count: 100 //总页数 ,count: 100 //总页数
}); });
console.log(lay('#footer').html());
//测试加载非内置模块 //测试加载非内置模块
/*
layui.config({ layui.config({
base: 'extends/' base: 'extends/'
}).extend({ }).extend({
mod1: 'mod1' mod1: 'mod1'
,mod2: 'mod2' ,mod2: 'mod2'
}).use('mod1'); }).use('mod1');
*/
//定义标题及数据源 //定义标题及数据源
@ -150,7 +156,21 @@ layui.use(function(){
}); });
} }
}); });
}); });
//})();
</script> </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> </body>
</html> </html>

@ -4,9 +4,7 @@
layui.define(function(exports){ layui.define(function(exports){
console.log('mod2.js') console.log('mod2.js')
layer.alert(1)
exports('mod2', { exports('mod2', {
name: 'mod2' name: 'mod2'
}) })

@ -105,7 +105,9 @@ layui.use('layer', function(){
}] }]
}); });
} }
}; };
$('.demo').on('click', function(){ $('.demo').on('click', function(){
var type = $(this).data('type'); var type = $(this).data('type');
active[type] ? active[type].call(this) : ''; active[type] ? active[type].call(this) : '';

@ -99,12 +99,12 @@
deps = [] deps = []
); );
that.use(deps, callback); that.use(deps, callback, null, 'define');
return that; return that;
}; };
//使用特定模块 //使用特定模块
Layui.prototype.use = function(apps, callback, exports){ Layui.prototype.use = function(apps, callback, exports, from){
var that = this var that = this
,dir = config.dir = config.dir ? config.dir : getPath ,dir = config.dir = config.dir ? config.dir : getPath
,head = doc.getElementsByTagName('head')[0]; ,head = doc.getElementsByTagName('head')[0];
@ -154,15 +154,15 @@
}()); }());
} }
} }
//回调 //回调
function onCallback(){ function onCallback(){
exports.push(layui[item]); exports.push(layui[item]);
apps.length > 1 ? apps.length > 1 ?
that.use(apps.slice(1), callback, exports) that.use(apps.slice(1), callback, exports, from)
: ( typeof callback === 'function' && function(){ : ( typeof callback === 'function' && function(){
//保证文档加载完毕再执行回调 //保证文档加载完毕再执行回调
if(layui.jquery && typeof layui.jquery === 'function'){ if(layui.jquery && typeof layui.jquery === 'function' && from !== 'define'){
return layui.jquery(function(){ return layui.jquery(function(){
callback.apply(layui, exports); callback.apply(layui, exports);
}); });

@ -459,7 +459,10 @@ layui.define('jquery', function(exports){
Element.prototype.render = Element.prototype.init; Element.prototype.render = Element.prototype.init;
var element = new Element(), dom = $(document); var element = new Element(), dom = $(document);
element.render();
$(function(){
element.render();
});
var TITLE = '.layui-tab-title li'; var TITLE = '.layui-tab-title li';
dom.on('click', TITLE, call.tabClick); //Tab切换 dom.on('click', TITLE, call.tabClick); //Tab切换

@ -699,7 +699,9 @@ layui.define('layer', function(exports){
var form = new Form() var form = new Form()
,$dom = $(document), $win = $(window); ,$dom = $(document), $win = $(window);
form.render(); $(function(){
form.render();
});
//表单reset重置渲染 //表单reset重置渲染
$dom.on('reset', ELEM, function(){ $dom.on('reset', ELEM, function(){

@ -393,16 +393,21 @@
}); });
}; };
//设置HTML内容 //设置或获取 HTML 内容
LAY.prototype.html = function(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; item.innerHTML = html;
}); });
}; };
//设置 //设置或获取
LAY.prototype.val = function(value){ 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; item.value = value;
}); });
}; };

Loading…
Cancel
Save