vue中使用render函数来写html
vue组件中使用 render 写法,像 react 的 render 写法一样
第一种
// 使用 react 写法
render () {
let { v, handleUp } = this;
return (
<ul>
<li class="txt-center" key={ v.id } on-click={this.handleUp.bind(this, v)} >
<img src={ v.pic } alt=""/>
<p class="jd-text-color Ft-S22">{v.name}</p>
</li>
</ul>
)
}
第二种
// 使用 createElement 方式写法
render (h) {
let { v, handleUp } = this;
return (
h('div', { class: 'txt-center' }, [
h("img", { attrs: { src: v.pic, alt: ''}, on: { click: () => handleUp(v) } }),
h("p", { class: 'jd-text-color Ft-S22' }, v.name)
])
)
}
End…