Javascript Vue js:如何清除应用的过滤器?

Javascript Vue js:如何清除应用的过滤器?,javascript,vue.js,Javascript,Vue.js,我在Vue Js中有下面的代码,我已经实现了对API数组元素的过滤,效果很好,现在我尝试设置一个按钮,当我单击它时清除过滤器,并返回页面,因为没有任何更改,但我下面的代码不起作用。它显示空数组问题,请提供帮助? 先谢谢你 最近问 {{问题1.问题} 透明过滤器 导出默认值{ 数据(){ 返回{ 问题:[], 回答:空, 索引:0, selectedIndex:null, } }, 方法:{ 选定答案(索引){ this.selectedIndex=索引; this.questions=t

我在Vue Js中有下面的代码,我已经实现了对API数组元素的过滤,效果很好,现在我尝试设置一个按钮,当我单击它时清除过滤器,并返回页面,因为没有任何更改,但我下面的代码不起作用。它显示空数组问题,请提供帮助? 先谢谢你

最近问
  • {{问题1.问题}
透明过滤器 导出默认值{ 数据(){ 返回{ 问题:[], 回答:空, 索引:0, selectedIndex:null, } }, 方法:{ 选定答案(索引){ this.selectedIndex=索引; this.questions=this.questions.filter((问题)=>question.error\u答案。包括(索引)) console.log(索引) }, ClearFilter(){ 这个。问题=[] }, 观察:{ 问题1:{ handler(){ this.selectedIndex=null; 这个答案是否定的; }, }, }, }, 挂载:函数(){ 取('https://opentdb.com/api.php?amount=10&category=9&difficulty=medium&type=multiple',{ 方法:“获取” }) 。然后((响应)=>{ 返回response.json() }) .然后((jsonData)=>{ this.questions=jsonData.results }) }, }
我不确定你的问题是否正确。但这可能有助于:

.then((jsonData) => {
  this.questions = jsonData.results;
  this.unmutated = jsonData.results;
})
单击“重置”按钮时

this.questions = this.unmutated 

是的,非常感谢!!!