报错翻译:TypeError:无法使用“ in”运算符在false中搜索“ name”

报错原因:在使用vue开发中,一个input绑定的对象被赋值成false了,当输入值就会报这个错

<input type="text" v-model="form.name" />
getResult('xxx/xxx',params)
            .then((res)=>{
               this.form = res 
            })

由于后台没取到值返回了一个false

TypeError: Cannot use 'in' operator to search for 'name' in false

 

 

 原因就是在vue内部在解析form这个对象时,由于被赋值成false了,绑定的数据类型已经被改变了,

就像上面翻译的一样:无法使用“ in”运算符在false中搜索“ name”

要解决这个问题就加判断

this.form = res ? res :{}

 

相关文章:

  • 2022-12-23
  • 2021-08-28
  • 2022-12-23
  • 2021-05-31
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-05-05
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2021-10-30
相关资源
相似解决方案