Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Vue JS多个过滤器,一个阵列_Javascript_Arrays_Vue.js - Fatal编程技术网

Javascript Vue JS多个过滤器,一个阵列

Javascript Vue JS多个过滤器,一个阵列,javascript,arrays,vue.js,Javascript,Arrays,Vue.js,我目前正在努力使我的代码能够正常运行。我正在尝试基于数组创建一些动态生成的对象(完成了)。我已经实现了一个搜索功能,并且在某一点上有一个可用的过滤器(只有一个)。我尝试链接过滤器,但失败了:')我需要能够搜索,并根据用户从3个类别(主题、价格、reviewstars)中选择的内容筛选数组,可以是一个或两个,也可以是全部 在过去12个小时的大部分时间里,我一直在努力解决这个问题。D:我真的不知道如何用我实现一切的方式来解决这个问题:/ 主要代码如下: let类={ 菜单:[ {主题:“数学”,地

我目前正在努力使我的代码能够正常运行。我正在尝试基于数组创建一些动态生成的对象(完成了)。我已经实现了一个搜索功能,并且在某一点上有一个可用的过滤器(只有一个)。我尝试链接过滤器,但失败了:')我需要能够搜索,并根据用户从3个类别(主题、价格、reviewstars)中选择的内容筛选数组,可以是一个或两个,也可以是全部

在过去12个小时的大部分时间里,我一直在努力解决这个问题。D:我真的不知道如何用我实现一切的方式来解决这个问题:/ 主要代码如下:

let类={
菜单:[
{主题:“数学”,地点:“adadadas”,价格:80,长度:“120”,时间:“9:00”,评论:“3”},
{主题:“数学”,地点:“达萨”,价格:90,长度:“70”,时间:“11:00”,评论:“4”},
{主题:数学,地点:达达斯,价格:120,长度:“30”,时间:“14:00”,评论:“1”},
{主题:'english',地点:'dasdsadas',价格:110,长度:“45”,时间:“13:00”,评论:“2”},
{主题:“英语”,地点:“fsafasf”,价格:90,长度:“75”,时间:“11:00”,评论:“4”},
{主题:'english',地点:'fafasa',价格:90,长度:“100”,时间:“17:00”,审稿人:“2”},
{主题:'english',地点:'fsasada',价格:130,长度:“90”,时间:“15:00”,评论:“3”},
{主题:“钢琴”,地点:“DSADS”,价格:120,长度:,时间:“50”,时间:“13:00”,评论:“4”},
{主题:“钢琴”,地点:“钢琴”,价格:140,长度:“40”,时间:“12:00”,评论:“1”}
],
输入:{
主题:“”,
地点:'全部',
主题:"所有",,
价格:'全部',
评论:“全部”
},
新的:[],
其他:【】,
filterText:null
};
var searchBar=新的Vue({
el:“#搜索栏”,
数据:类别,
计算:{
menuArray(){
让vm=这个
让数组=新集合()
vm.menu.forEach(函数(项){
array.add(item.location)
})
console.log(数组)
返回vm.newAry=Array.from(数组)
},
menuArrayReview(){
让vm=这个
让数组=新集合()
vm.menu.forEach(函数(项){
array.add(item.reviewStars)
})
console.log(数组)
返回vm.newAry=Array.from(数组)
},
menuArrayTopic(){
让vm=这个
让数组=新集合()
vm.menu.forEach(函数(项){
array.add(item.topic)
})
console.log(数组)
返回vm.newAry=Array.from(数组)
},
menuArrayPrice(){
让vm=这个
让数组=新集合()
vm.menu.forEach(函数(项){
array.add(item.price)
})
console.log(数组)
返回vm.newAry=Array.from(数组)
},
filterTypeTopic(){
让vm=这个
如果(vm.input.topic!=='All'){
返回vm.otherAry.filter(函数(项){
return item.topic==vm.input.topic
})
}否则{
返回vm.otherAry
}
},
filterTypePrice(){
让vm=这个
如果(vm.input.price!=“全部”){
返回vm.otherAry.filter(函数(项){
return item.price==vm.input.price
})
}否则{
返回vm.otherAry
}
},
filterTypeReviews(){
让vm=这个
如果(vm.input.review!=='All'){
返回vm.otherAry.filter(函数(项){
return item.reviewStars===vm.input.review
})
}否则{
返回vm.otherAry
}
},
filterAryTopic(){
让vm=这个
if(vm.input.topic){
返回vm.filterTypeTopic().filter(函数(项){
让content=item.topic.toLowerCase()
let关键字=vm.input.topic.toLowerCase()
返回内容。indexOf(关键字)!=-1
})
}否则{
返回vm.filterTypeTopic
}
},
过滤器价格(){
让vm=这个
if(vm.input.price){
返回vm.filterTypePrice.filter(函数(项){
让content=item.price.toLowerCase()
let关键字=vm.input.price.toLowerCase()
返回内容。indexOf(关键字)!=-1
})
}否则{
返回vm.filterTypePrice
}
},
filterAryReviews(){
让vm=这个
if(vm.input.review){
返回vm.filterTypeReviews().filter(函数(项){
让content=item.reviewStars.toLowerCase()
let关键字=vm.input.review.toLowerCase()
返回内容。indexOf(关键字)!=-1
})
}否则{
vm.menu=vm.filterTypeReviews()
}
},
filterType(){
让vm=这个
如果(vm.input.location!=='All'){
返回vm.otherAry.filter(函数(项){
return item.location==vm.input.location
})
}否则{
返回vm.menu
}
},
过滤器{
让vm=这个
if(vm.input.topic){
返回vm.filterType.filter(函数(项){
让content=item.topic.toLowerCase()
let关键字=vm.input.topic.toLowerCase()
返回内容。indexOf(关键字)!=-1
})
}否则{
返回vm.filterType
}
},
格塔里{
让vm=这个
返回vm.otherAry
}
},
挂载:函数(){
newAry=类;
}
})

活动!
全部的
{{item}}
全部的
{{item}}
全部的
{{item}}
  • {{item.location}
  • {{i