zoukankan      html  css  js  c++  java
  • vue的filter用法,检索内容

    var app5 = new Vue({
    el: '#app5',
    data: {
    shoppingList: [
    "Milk",
    "Donuts",
    "Cookies",
    "Chocolate",
    "Peanut Butter",
    "Pepto Bismol",
    "Pepto Bismol (Chocolate flavor)",
    "Pepto Bismol (Cookie flavor)" ],
    key: ""
    },
    computed: {
    filterShoppingList: function () { // `this` points to the vm instance
    var key = this.key;
    var shoppingList = this.shoppingList; //在使用filter时需要注意的是,前面调用的是需要使用filter的数组,而给filter函数传入的是数组中的每个item,也就是说filter里面的函数,是每个item要去做的,并将每个结果返回。
    return shoppingList.filter(function (item) {
    return item.toLowerCase().indexOf(key.toLowerCase()) != -1 });;
    }
    }
    })

    <ul> Filter Key<input type="text" v-model="key"> <li v-for="item in filterShoppingList"> {{ item }} </li> </ul>

      

  • 相关阅读:
    https://leetcode-cn.com/problems/binary-search/solution/er-fen-cha-zhao-by-leetcode/
    Question_add-two-numbers
    leetcode merge-two-sorted-lists
    leetcode 1108
    leetcode 1107
    git
    sql 语句
    cas
    OMP 算法
    OC----预处理器
  • 原文地址:https://www.cnblogs.com/holy-amy/p/8436502.html
Copyright © 2011-2022 走看看