如何在vue js中的过滤器搜索中添加大于等于的条件

how to add a condition like a greater than equal to in filter search in vue js

大家好,我要开发一个房地产应用程序 我想在卧室过滤器功能中添加条件,例如 "greater than equal "

例如:- 如果卧室列表中有 select 2 个,我想过滤大于等于 2 个卧室的属性

我该怎么做

export default {
  data() {
    return {
      blogs: [],
      minbed: this.$route.params.bed,
    }
  },
  created() {
    this.$http.get("https://test.json").then(function(data) {
      console.log(data);
      this.blogs = data.body;
    });
  },
  computed: {
    filteredList() {
      const { blogs, search, UnitType } = this;
      return this.blogs
        .filter(blog => blog.Bedrooms.includes(this.minbed))
  }
}
<select
  v-model="minbed"
  id="formInput202"
  class="form-control"
  value="MaxBedrooms"
>
  <option>Max.Bedrooms</option>
  <option>1</option>
  <option>2</option>
  <option>3</option>
  <option>4</option>
  <option>5</option>
  <option>ST</option>
</select>

includes 方法在这种情况下不起作用。只接受字符串作为参数 (Ref-Link1).

内联回调函数会解决这个问题,

检查下面的代码。

filteredList() {
    const { blogs, search, UnitType } = this;
    var MaxBedroomsVal = this.minbed;
    return this.blogs.filter( function (blog) { 
        return blog.Bedrooms >= MaxBedroomsVal;
    })
}

参考:Link2