vue分页练习

<!doctype html>
<html>
 <head>
  <meta charset="UTF-8">
  <title>分页练习</title>
    <script src="js/vue.js"></script>
 </head>
 <style>
    .isList{
        list-style:none;
    }
    .isPadding{
        margin:5px;
        padding:5px;
        border:2px solid gray;
    }
    .isRed{
        color:red;
    }
 </style>
 <body>
  <div id="container">
        <p>{{msg}}</p>
        <ul v-bind:class="{isList:listStyle}">
            <li v-for="(tmp,index) in pageNumbers"
            v-bind:style="{float:isFloat}" 
            v-bind:class="{isPadding:isStyle,isRed:index==pageOne}" 
            @click="changeBg(index)">{{tmp}}</li>
        </ul>
    </div>
    <script>
        new Vue({
            el:"#container",
            data:{
                msg:"Hello VueJs",
                listStyle:true,
                isFloat:"left",
                isStyle:true,
                pageNumbers:[1,2,3,4,5],
                pageOne:0
            },
            methods:{
                changeBg:function(myIndex){
                    this.pageOne = myIndex;
                }
            }
        })
    </script>
 </body>
</html>
<!doctype html>
<html>
 <head>
  <meta charset="UTF-8">
  <title></title>
    <style>
        ul    {
            list-style:none;
        }
        li{
            padding:10px;
            margin:5px;
            border:1px solid gray;
            float:left;
        }
        .isRed{
            color:red;
        }
    </style>
    <script src="js/vue.js"></script>
 </head>
 <body>
  <div id="container">
        <p>{{msg}}</p>
        <ul>
            <li v-for="(tmp,index) in pageNumbers" v-bind:class="{isRed:index==pageNo}" @click="handleClick(index)">{{tmp}}</li>
        </ul>
    </div>
    <script>
        new Vue({
            el:"#container",
            data:{
                msg:"Hello VueJs",
                pageNumbers:[1,2,3,4,5],
                pageNo:0
            },
            methods:{
                handleClick:function(myIndex){
                    this.pageNo = myIndex;
                }
            }
        })
    </script>
 </body>
</html>

 

posted @ 2017-11-01 10:20  匿名的girl  阅读(271)  评论(0编辑  收藏  举报