//页面index.ejs
<script type="text/javascript">
//已经确定session里有page对象
var options ={
currentPage :page.currentPage,
totalPages : page/totalPages
}
$('#page1').bootstrapPaginator(options);
</script>
!!!!!为什么 options的赋值不成功呢? 整个分页条就不显示了,直接写入数字的话,是能显示的。
//路由routes/index.js
app.get('/’, function(req, res){
if(!req.session.user){
res.render('index’, { title: '首页-Microblog’});
} else {
var page = new Page({
currentPage:1,
totalPages:0
});
page.getPage(function(totalPages){
page.totalPages = totalPages;
});
page.select(function(rows){
var says = [];
for(var i in rows){
says.push(rows[i]);
}
req.session.says = says;
req.session.page = page;
//这里传送的page
res.render('index’, { title: '首页-Microblog’});
});
}
});