Validation 实时搜索Vuew的验证

Validation 实时搜索Vuew的验证,validation,search,input,vue.js,render,Validation,Search,Input,Vue.js,Render,嘿, 我在验证Vue中的实时搜索时遇到问题。我已经尝试了很多次,但最终我无法成功。。 有人能告诉我如何开始写这个验证吗? 例子: 如果我在搜索中键入不存在的内容,请发出警报 <input type="text" v-model="search" placeholder="Search..." class="search" /> export default { data(){ return { users: [], search: ''

嘿, 我在验证Vue中的实时搜索时遇到问题。我已经尝试了很多次,但最终我无法成功。。 有人能告诉我如何开始写这个验证吗? 例子: 如果我在搜索中键入不存在的内容,请发出警报

      <input type="text" v-model="search" placeholder="Search..." class="search" />

export default {
  data(){
    return {
    users: [],
    search: ''
  }
},
  mounted(){
    fetch("https://api.github.com/users?since=135")
    .then(response => response.json())
    .then((data) => {
      this.users = data;
    // console.log(data);
    })
  },
  computed:{
    filteredUsers: function(users){
      return this.users.filter((users) => {
        return users.login.toLowerCase().includes(this.search.toLowerCase())
  });
   }
  },
}

导出默认值{
数据(){
返回{
用户:[],
搜索:“”
}
},
安装的(){
取回(“https://api.github.com/users?since=135")
.then(response=>response.json())
。然后((数据)=>{
这个用户=数据;
//控制台日志(数据);
})
},
计算:{
filteredUsers:函数(用户){
返回此.users.filter((用户)=>{
return users.login.toLowerCase().includes(this.search.toLowerCase())
});
}
},
}

我怀疑If-else语句应该放在哪个渲染之间。

您有任何控制台错误吗?没有,我没有。实时搜索正在完美地工作。我在验证中堆叠。此的html代码在哪里。用户?您可以在vue html中添加if-else条件