layui-js/examples/base.html

99 lines
1.9 KiB
HTML
Raw Normal View History

2021-05-18 02:42:31 +08:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
2021-05-31 08:57:00 +08:00
<title>基础方法测试用例 - layui</title>
2021-05-18 02:42:31 +08:00
<link rel="stylesheet" href="../src/css/layui.css">
</head>
<body>
<div class="layui-container" style="padding: 30px 0;">
<div class="" style="padding: 30px 0;">
<blockquote class="layui-elem-quote" style="color: #666;">
调试结果查看浏览器控制台
</blockquote>
</div>
</div>
<script src="../src/layui.js"></script>
<script>
layui.use('lay', function(){
2021-05-31 08:57:00 +08:00
var lay = layui.lay;
2021-05-18 02:42:31 +08:00
2021-05-31 08:57:00 +08:00
//sort
console.log(
'layui.sort: 数字',
layui.sort([{a: 3},{a: 0},{a: 0},{a: -1},{a: -5},{a: 6},{a: 9},{a: -333333}], 'a')
);
console.log(
'layui.sort: 中文',
layui.sort([{a: '男'},{a: '女'},{a: '男'},{a: '女'},{a: '男'}], 'a')
);
console.log(
'layui.sort: 英文',
layui.sort([{a: 'E'},{a: 'B'},{a: 'D'},{a: 'C'},{a: 'A'}], 'a')
);
2021-05-18 02:42:31 +08:00
console.log(
2021-05-31 08:57:00 +08:00
'layui.sort: 混合'
,layui.sort([
{a: 3}
,{a: '男'}
,{a: 0}
,{a: 66}
,{a: 99}
,{a: 'C'}
,{a: '女'}
,{a: 0}
,{a: -1}
,{a: 'B'}
,{a: '男'}
,{a: 'A'}
,{a: -5}
,{a: '男'}
,{a: 6}
,{a: 9}
], 'a')
2021-05-18 02:42:31 +08:00
);
2021-05-31 08:57:00 +08:00
2021-05-18 02:42:31 +08:00
console.log(
'layui._typeof: ',
2021-05-31 08:57:00 +08:00
layui._typeof(new RegExp()),
layui._typeof(new Date()),
layui._typeof([])
2021-05-18 02:42:31 +08:00
);
console.log(
'layui._isArray ',
2021-05-31 08:57:00 +08:00
layui._isArray([1,6]),
layui._isArray(lay('div')),
layui._isArray(document.querySelectorAll('div')),
2021-05-18 02:42:31 +08:00
layui._isArray({key: 'value'})
);
2021-05-31 08:57:00 +08:00
console.log(
'lay.extend {}: ',
lay.extend(
{},
{a: 123, c: {ccc: 'ccc'}, arr: [1,3]},
{a: 111, b: 1, c: {bbb: 'bbb'}},
{a: 222222, arr: [5]}
)
);
console.log(
'lay.extend []: ',
lay.extend([], [1,3,5])
);
2021-05-18 02:42:31 +08:00
});
</script>
</body>
</html>