Problem scenario
Use {} text interpolation to display content through cascade. In the following code, foo returns through the back-end interface.
Before the back-end content returns, the console will not read the property ‘xxx’ of undefined.
<div>
<h1>{{ foo.title }}</h1>
<p>{{ foo.description }}</p>
</div>
Solution
<div>
<h1 v-if="foo.title">{{ foo.title }}</h1>
<p v-if="foo.description">{{ foo.description }}</p>
</div>
perhaps
<div>
<template v-if="foo">
<h1>{{ foo.title }}</h1>
<p>{{ foo.description }}</p>
</template>
</div>
perhaps
new Vue({
foo: {
title: '',
description : ''
},
created(){
// Calling the back-end interface
}
})
Read More:
- [Solved] Vue element UI form verification error: cannot read property ‘validate’ of undefined
- [Solved] Vue Error: TypeError: Cannot read property ‘end‘ of undefined
- Uni-app Error when assigning a value to a component: [system] TypeError: Cannot read property ‘name‘ of undefined
- [Solved] Syntax Error: TypeError: Cannot read property ‘parseComponent‘ of undefined
- [Solved] Syntax Error: TypeError: Cannot read property ‘parseComponent‘ of undefined
- [Solved] Cannot read property ‘setCheckedKeys‘ of undefined“
- Cannot read property ‘isFile‘ of undefined [How to Solve]
- [Solved] HBuilder Error: Cannot read property ‘forceUpdate‘ of undefined
- [Solved] electron Error: Uncaught TypeError: Cannot read property ‘BrowserWindow‘ of undefined
- [Solved] Install The Latest Version of Jest Error: TypeError: Cannot read property ‘instrument‘ of undefined
- [Solved] TYPEERROR: CANNOT READ PROPERTY ‘REDUCE‘ OF UNDEFINED
- Echarts Partially introduced error: TypeError: Cannot read property ‘findAxisModel’ of undefined
- [Solved] Echarts Error: Cannot read property ‘init‘ of undefined
- [Solved] vue.esm.js?efeb:591 [Vue warn]: Error in event handler for “click“: “TypeError: Cannot read property
- [Solved] Vue Project Error: “TypeError: Cannot read properties of undefined (reading ‘init‘)“
- Echarts Map Error: Error: Invalid geoJson format Cannot read property ‘length‘ of undefined
- [Solved] Element form method resetfields() error: vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of undefined (reading ‘indexOf’)
- [Solved] vue watch Error: Error in callback for watcher “xxx“: “TypeError: Cannot read properties of undefined …
- [Solved] VUE Error: Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ‘$on‘)“
- Vue form validate error: Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘indexOf‘)