Demand
It is expected to dynamically render page components through array objects
method
Use the render method to create a component based on the type field of the object through $createElement and pass other parameters into the component
renderParent($h,parent) {
const values = this.values
const field = parent.options.field
let value ;
if(field){
value = values[field]
}
return $h(parent.type,{
props:{options:parent.options,value:value},on:{'change:value':(val) => {this.update(field,val)}}
},parent.children ?parent.children
.map(child => {
if(typeof child === 'string') return child
if(child.type){
return this.renderParent($h,child)
}
}) : ""
)
},
result
The following error is reported:
solve
When creating a component through ceateelement, add attrs attribute in the second parameter
Read More:
- uniapp [Vue warn]: Error in onLoad hook: “TypeError: Attempting to change the setter of an unconfigu
- [Vue warn]: Error in render: “TypeError: Cannot read properties of undefined
- [Vue warn]: Error in render: “TypeError: Cannot read properties of undefined
- [Solved] Error in callback for watcher “value“: “TypeError: Cannot read property ‘level‘ of null“
- [Solved] Element Error: Error in render: TypeError: dateStr.match is not a function“
- [Solved] VUE Error: Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ‘$on‘)“
- [Solved] TYPEERROR: CANNOT READ PROPERTY ‘REDUCE‘ OF UNDEFINED
- [Solved] vue.esm.js?efeb:591 [Vue warn]: Error in event handler for “click“: “TypeError: Cannot read property
- 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
- Echarts Partially introduced error: TypeError: Cannot read property ‘findAxisModel’ of undefined
- [Solved] Vue Error: TypeError: Cannot read property ‘end‘ of undefined
- [Solved] electron Error: Uncaught TypeError: Cannot read property ‘BrowserWindow‘ of undefined
- JS bug Log Uncaught TypeError: Cannot read property ‘previoustSibling‘ of null
- [Solved] Syntax Error: TypeError: Cannot read property ‘parseComponent‘ of undefined
- [Solved] Uni.createintersectionobserver Error: Uncaught TypeError: Cannot read property ‘bottom’ of null
- [Solved] Install The Latest Version of Jest Error: TypeError: Cannot read property ‘instrument‘ of undefined
- [Vue warn]: Error in callback for watcher “fileList”: “TypeError: Cannot create property ‘uid’ on string
- [Solved] PDF.js Error: Cannot use the same canvas during multiple render()
- Vue Error: error in mounted hook: TypeError: invalid src type