Skip to content

Commit

Permalink
20180731
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyue0503 committed Jul 31, 2018
1 parent ea87511 commit 2fdc8f9
Show file tree
Hide file tree
Showing 5 changed files with 818 additions and 0 deletions.
21 changes: 21 additions & 0 deletions nodejs系列/10/1.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
doctype
html(lang="en")
head
meta(charset="UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
meta(http-equiv="X-UA-Compatible", content="ie=edge")
title Document
style.
ol li{float:left;margin:30px;list-style:none;}
.active{color:red;}
body
ul
-for(var i=0;i < listArr.length;i++)
li=listArr[i]
ol
-for(var i=0;i<maxl;i++)
li
if(i==index-1)
a.active(href="http://localhost:8020/list?page="+(i+1))=i+1
else
a(href="http://localhost:8020/list?page="+(i+1))=i+1
43 changes: 43 additions & 0 deletions nodejs系列/10/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var express = require('express');
var jade = require('jade');

var listRouter = express.Router();

var server = express();

server.listen(8020);

var arr = [
'aaaaaaaaa',
'bbbbbbbbb',
'ccccccccc',
'ddddddddd',
'eeeeeeeee',
'fffffffff',
'ggggggggg',
'aaaaaaaaa-1',
'bbbbbbbbb-1',
'ccccccccc-1',
'ddddddddd-1',
'eeeeeeeee-1',
'fffffffff-1',
'ggggggggg-1',
'aaaaaaaaa-2',
'bbbbbbbbb-2',
'ccccccccc-2',
'ddddddddd-2',
'eeeeeeeee-2',
'fffffffff-2',
'ggggggggg-2',
];

server.use('/list',listRouter);

listRouter.use('',function(req,res){
// console.log(1);
var needArr = arr.slice((req.query.page-1)*4,req.query.page*4);
var maxLi = Math.ceil(arr.length/4);
var str = jade.renderFile('./1.jade',{pretty:true,listArr:needArr,maxl:maxLi,index:req.query.page});

res.send(str);
});
Loading

0 comments on commit 2fdc8f9

Please sign in to comment.