Complete the code to create a simple Vue render function that returns a <div> with text.
export default {
render() {
return [1]('div', 'Hello Vue!')
}
}The h function is a common alias for the createElement function used in Vue render functions.
Complete the code to pass props to a child component using a render function.
export default {
render() {
return this.$createElement('ChildComponent', { props: { message: [1] } })
}
}In Vue render functions, to pass props, you use this to access component data or props.
Fix the error in the render function to correctly render a list of items.
export default {
data() {
return { items: ['a', 'b', 'c'] }
},
render() {
return this.items.map(item => [1]('li', item))
}
}The render function needs the h function to create elements inside the map.
Fill both blanks to create a render function that conditionally renders a <p> or <span> element.
export default {
data() {
return { isParagraph: true }
},
render() {
return this.isParagraph ? [1]('p', 'Paragraph') : [2]('span', 'Span')
}
}Both blanks need the element creator function. h and createElement are common names for it.
Fill all three blanks to create a render function that returns a <ul> with <li> children from an array.
export default {
data() {
return { fruits: ['apple', 'banana', 'cherry'] }
},
render() {
return [1]('ul', this.fruits.map(fruit => [2]('li', [3])))
}
}The outer render function uses render, inside the map use createElement and the current fruit as text.