Vue 警告我无法在未定义、null 或原始值上设置反应式属性:null

新手上路,请多包涵

Firebase 获取数据时,我正在尝试设置 propertiesobject 获得的数据,但当我尝试更改数据和 UI 时它抛出这个错误。

v-on 处理程序中的错误:“TypeError:无法使用‘in’运算符在 null 中搜索‘cc’。

我在开发模式下使用 Vue 以及 Firebase 。我是否遗漏了任何概念?

 beforeCreate(){
sref.get().then(sc => {
      if (sc.exists) {
        console.log(sc.data()); //this logs in the correct data
        this.school = sc.data(); //this too
        this.cc = sc.data().cc;  //also this
        this.name = sc.data().name;

当我做

console.log(this.name)

created() 它显示未定义,任何更改或更新的尝试也会出错

Vue warn]: Cannot set reactive property on undefined, null, or primitive value: null
[Vue warn]: Error in v-on handler: "TypeError: Cannot use 'in' operator to search for 'cc' in null"

found in

---> <VSelect>
       <VForm>
         <VCard>

TypeError: Cannot use 'in' operator to search for 'cc' in null
    at Proxy.set

原文由 Aditya 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 586
1 个回答

I figured out where I went wrong there, in my template v-model i was using this.school , this.name , this.cc which was causing the warnings来,但我仍然不清楚工作的内部。我想如果有人指出我正确的资源。

原文由 Aditya 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题