• 模糊搜索的用法


    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
    <div id="app">
        <input type="text" v-model='search' />
        <ul v-for="item in searchData ">
            <li>{{item.name}},价格:¥{{item.price}}</li>
        </ul>
    </div>
    <script src="vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                search: '',
                products: [{
                    name: '苹果',
                    price: 25,
                    category: "水果"
                }, {
                    name: '香蕉',
                    price: 15,
                    category: "水果"
                }, {
                    name: '雪梨',
                    price: 65,
                    category: "水果"
                }, {
                    name: '宝马',
                    price: 2500,
                    category: "汽车"
                }, {
                    name: '奔驰',
                    price: 10025,
                    category: "汽车"
                }, {
                    name: '柑橘',
                    price: 15,
                    category: "水果"
                }, {
                    name: '奥迪',
                    price: 25,
                    category: "汽车"
                }, {
                    name: '火龙果',
                    price: 25,
                    category: "工具"
                }]
            },
            computed: {
                searchData: function() {
                    var search = this.search;
                    if (search) {
                        return this.products.filter(function(product) {
                            return Object.keys(product).some(function(key) {
                                return String(product[key]).toLowerCase().indexOf(search) > -1
                            })
                        })
                    }
    
                    return this.products;
                }
            }
        })
    </script>
    </body>
    </html>
    

      

  • 相关阅读:
    CDK上安装kube-dashboard
    JBoss入门
    CDK安装
    minishift安装
    Openshift中Configmap的使用
    每天5分钟玩转Docker
    Openshift初步学习问题集
    pyinstaller深入使用,打包指定模块,打包静态文件
    firefox 开启安全禁用端口
    使用VirtualBox把IMG文件转换为VDI文件
  • 原文地址:https://www.cnblogs.com/wb336035888/p/7418008.html
Copyright © 2020-2023  润新知