简体   繁体   English

渲染错误:“TypeError:无法在 vue js 中将未定义或 null 转换为对象”?

[英]Error in render: “TypeError: Cannot convert undefined or null to object” in vue js?

Everythings works fine and im also getting the data but im getting this javascript error.一切工作正常,我也得到了数据,但我得到了这个 javascript 错误。

I have following network request我有以下网络请求

    data: {
    patient: null
    }
    methods: {
    
    
    //call methods to add patients
    setPatient(patient) {
          this.patient = patient;
        },
      }
//network request in navigation guard
  async beforeRouteEnter(to, from, next) {
    await axios
      .post(route("api.patient.ids"), { ids: [to.params.id] })
      .then((res) => {
        if (res.data.length) {
          next((vm) => {
            // console.log(typeof res.data[0]);
            vm.setPatient(res.data[0]);
          });
        }
      });
  },

chrome开发工具错误

somebody could explain whats causing the problem?有人可以解释导致问题的原因吗?

Place a v-if="patient" on any template element which requires patient to be an object.在要求patient为 object 的任何模板元素上放置一个v-if="patient" Your patient is null initially, until the API call returns and you commit it.您的patient最初是null ,直到 API 调用返回并且您提交它。

In your case:在你的情况下:

<health-condition v-if="patient"
                  :patient="patient"
                  @openForm="toggleFormTable" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 数据()中的Vue警告错误“类型错误:无法将未定义或空值转换为对象” - Vue warning Error in data() "TypeError: Cannot convert undefined or null to object" 错误TypeError:无法将未定义或null转换为对象 - error TypeError: Cannot convert undefined or null to object "Vue.js 应用程序中的“TypeError:使用过滤方法时无法将未定义或 null 转换为对象”" - The "TypeError: Cannot convert undefined or null to object" when using filter method" in Vue.js application Vue.JS:未捕获(承诺)类型错误:无法将未定义或 null 转换为 object - Vue.JS: Uncaught (in promise) TypeError: Cannot convert undefined or null to object React JS:TypeError:无法将未定义或空值转换为对象 - React JS: TypeError: Cannot convert undefined or null to object 未捕获的类型错误:无法将未定义或 null 转换为 object React JS - Uncaught TypeError: Cannot convert undefined or null to object React JS [Vue警告]:渲染错误:“ TypeError:对象未定义” - [Vue warn]: Error in render: “TypeError: object is undefined” ReactJS 错误 TypeError:无法将 undefined 或 null 转换为对象 - ReactJS error TypeError: Cannot convert undefined or null to object json数据错误未捕获的TypeError:无法将未定义或null转换为对象 - json data error Uncaught TypeError: Cannot convert undefined or null to object 服务器错误:类型错误:无法将未定义或 null 转换为 object - Server Error : TypeError: Cannot convert undefined or null to object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM