zoukankan      html  css  js  c++  java
  • filter函数示例

    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <script src="../js/vue.js"></script>
    </head>

    <body>
        <div id="app">
            <li v-for="item in evenlist">{{item}}</li>
            <li v-for="item in odd(list)">{{item}}</li>
        </div>
        <script>
            var vm = new Vue({
                el: "#app",
                data: {
                    list: [1, 2, 3, 4, 5, 6, 7, 8, 9]
                },
                computed:{
                    evenlist:function(){
                        return this.list.filter(function(number){
                            return number%2===0;
                        })
                    }
                },
                methods:{
                    odd:function(list){
                        return list.filter(function(v){
                            return v%2!==0;
                        })
                    }
                }
            })
        </script>
    </body>

    </html>
  • 相关阅读:
    黑客是如何知道我们常用的密码的
    一个核物理学霸为何两次收到BlackHat的邀请
    透过大数据剖析漫画何去何从
    SJF(最短作业优先)
    RR(轮转调度算法)
    hrrf(最高响应比)
    fcfs
    Process 2(完成版)
    进程2
    进程1
  • 原文地址:https://www.cnblogs.com/kukai/p/12416071.html
Copyright © 2011-2022 走看看