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:
- [Solved] react-router-dom Error: index.js:1 Warning: Functions are not valid as a React child.
- How to Solve VUE Error: Avoid mutating a prop directly since the value will be overwritten …
- Vue refreshes the current page (no flash screen will appear)
- The addition, deletion and modification of DOM in JS Foundation
- React error boundary (What You Should Know & How to Solve)
- Vue warn]: vue3 element Component emit Pass Event Error
- [Solved] Error: Incorrect arguments to mysqld_stmt_execute
- [Vue warn]: Invalid prop: type check failed for prop [How to Solve]
- Vue displays 404 and 500 interfaces according to HTTP response status
- Vue modifies the value passed by props error: Avoid mutating a prop directly since the value will be overwritten whenever the par
- [Solved] Error in callback for watcher “value“: “TypeError: Cannot read property ‘level‘ of null“
- [Solved] Invalid prop: type check failed for prop “modelValue“. Expected Number…
- Vue2.0: How to Use vue3 api to encapsulate Axios
- @requestbody: How to Use or Not Use
- [Solved] vue-roter 4 Error: Error: Invalid route component/Uncaught (in promise) Error: Invalid route component
- Vue wran name Error: Unkown custom element [How to Solve]
- [Solved] Font End Image Display Error: net::ERR_CONNECTION_RESET 431 (Request Header Fields Too Large)
- [Go] Can structure/structure pointer be compared with operator == is not defined error
- How to Solve Props value transfer International Language error
- [Solved] Vue Error: Duplicate keys detected: ‘74004’. This may cause an update error