You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
layui/examples/code.html

175 lines
3.8 KiB

7 years ago
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>代码修饰器 - layui</title>
<link rel="stylesheet" href="../src/css/layui.css">
<style>
body{padding: 50px 100px;}
pre{margin-bottom: 20px;}
</style>
</head>
<body>
<pre class="layui-code" lay-title="JavaScript" lay-line-no="true" lay-height="300px">
//路由
LAY.fn.router = function(hash){
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
for(var i = 0; i < hashs.length; i++){
item = hashs[i].split('=');
/^\w+=/.test(hashs[i]) ? function(){
if(item[0] !== 'dir'){
param[item[0]] = item[1];
}
}() : param.dir.push(hashs[i]);
item = null;
}
return param;
};
</pre>
<pre id="line-no">
7 years ago
//路由
LAY.fn.router = function(hash){
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
for(var i = 0; i < hashs.length; i++){
item = hashs[i].split('=');
/^\w+=/.test(hashs[i]) ? function(){
if(item[0] !== 'dir'){
param[item[0]] = item[1];
}
}() : param.dir.push(hashs[i]);
item = null;
}
return param;
};
</pre>
<pre class="layui-code" lay-skin="notepad" lay-line-no="true">
7 years ago
//路由
LAY.fn.router = function(hash){
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
for(var i = 0; i < hashs.length; i++){
item = hashs[i].split('=');
/^\w+=/.test(hashs[i]) ? function(){
if(item[0] !== 'dir'){
param[item[0]] = item[1];
}
}() : param.dir.push(hashs[i]);
item = null;
}
return param;
};
</pre>
<pre class="layui-code" lay-line-no="true">
7 years ago
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
<pre class="layui-code" lay-title="不显示行号">
7 years ago
//代码中的代码
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
<pre class="layui-code" lay-line-no="true">
//代码中的代码
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
</pre>
7 years ago
</pre>
</pre>
<pre class="layui-code" lay-skin="notepad" lay-line-no="true">
7 years ago
//路由
LAY.fn.router = function(hash){
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
for(var i = 0; i < hashs.length; i++){
item = hashs[i].split('=');
/^\w+=/.test(hashs[i]) ? function(){
if(item[0] !== 'dir'){
param[item[0]] = item[1];
}
}() : param.dir.push(hashs[i]);
item = null;
}
return param;
};
<pre class="layui-code" lay-skin="notepad" lay-line-no="true">
7 years ago
//代码中的代码
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
<pre class="layui-code" lay-skin="notepad" lay-title="不显示行号">
7 years ago
//代码中的代码
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
<pre class="layui-code" lay-skin="notepad" lay-line-no="true">
7 years ago
//代码中的代码
var hashs = (hash || location.hash).replace(/^#/, '').split('/') || [];
var item, param = {
dir: []
};
</pre>
</pre>
</pre>
</pre>
<pre class="layui-code" lay-encode="true" lay-line-no="true">
7 years ago
<div>
123
</div>
</pre>
<pre id="about">
about
</pre>
7 years ago
<script src="../src/layui.js"></script>
<script>
layui.use('code', function(){
layui.code();
layui.code({
elem: '#line-no',
title: 'JavaScript不显示行号',
lineNo: false,
height: '300px'
});
layui.code({
elem: '#about',
title: '右侧 About',
about: 'code'
})
7 years ago
});
</script>
</body>
</html>