错误代码
export default {
data() {
return {
isRed: false,
arr: [1, 2, 3, 4],
inputValue: ''
}
},
render(h) {
return h(
'ul',
this.arr.map(item => { h('li', item) })
// 返回的函数里面不能存在 {} 大括号
// 要不然无法显示
)
}
}正确代码
export default {
data() {
return {
isRed: false,
arr: [1, 2, 3, 4],
inputValue: ''
}
},
render(h) {
return h(
'ul',
this.arr.map(item => h('li', item))
// 箭头函数里面去掉 {} 大括号
)
}
}