EJS receives back-end data to realize local paging


Back end data

var arr=[];
for(let i=0;i<77;i++){
        head: '<h3>ccccccccc</h3>',
        content: '<div>qqqqqqqq,qqqqqqqqqvvvvvvvv<p>cccccc,,cccccc</p></div>'
router.get('/', function(req, res, next) {
    res.render('index', {
        News: JSON. Stringify (ARR), // the key is to convert strings

Front desk HTML

<div id="content">
    <% var newslist=JSON.parse(news);newslist.forEach(function(item,key){%>
            <div style="margin-bottom: 10px;">
                <%- item.index%>
                <%- item.content%>
<div id="pages"></div>

JS part

var newslist = JSON.parse('<%-news%>');
function getList(index){
    var reslut= newslist.slice((index-1)*10,index*10);    
    var dof=document.createDocumentFragment();
    reslut.forEach(element => {
        $(dof).append(`<div style="margin-bottom:10px">${element.index} ${element.head} ${element.content}</div>`)

new Pagination({
    Element: '#pages', // element        
    Type: 2, // style type, optional [1,2]
    PageIndex: 1, // initial page number       
    PageSize: 10, // number of pages       
    Pagecount: 9, // number of pages       
    Total: newslist.length, // total number of data        
    Jumper: false, // display input box jump        
    Singlepagehide: true, // paging is not displayed when there is only one page       
    Prevtext: 'prev', // previous page text        
    Nexttext: 'next', // next page text       
    Disabled: true, // whether to display disabled        
    currentChange: function (index) {
        //Callback when page number changes         

In the example, a paging plug-in is used. You can find similar ones by yourself. There are many, but you can’t find a claw