I'm trying to convert JSX code from example at http://element.eleme.io/#/en-US/component/tree#custom-node-content to Vue $createElement code
original code snippet:
renderContent(h, { node, data, store }) {
return (
<span>
<span>
<span>{node.label}</span>
</span>
<span style="float: right; margin-right: 20px">
<el-button size="mini" on-click={ () => this.append(store, data) }>Append</el-button>
<el-button size="mini" on-click={ () => this.remove(store, data) }>Delete</el-button>
</span>
</span>);
}
}
and my attempt to transform:
renderContent (h, { node, data, store }) {
return h('SPAN', [
h('SPAN', [h('SPAN', node.label)]),
h('SPAN', {attrs: {style: 'float: right; margin-right: 20px'}}, [
h('el-button', { attrs: { size: 'mini', on: { click: this.append(store, data) } } }, 'Append'),
h('el-button', { attrs: { size: 'mini', on: { click: this.delete } } }, 'Delete')
])
])
}
but it fails: the button Append always executed at the time of rendering for every node and never after. While button Delete is never executed at all.
So the question is how to pass an event handler with arguments properly to the created element?