我有以下VueJS组件:重写VueJS组件使用JSX和渲染功能
Vue.component('label-ui', {
props: ['type', 'size', 'color', 'position'],
template: `
<div :class="[type, size, color, position]" class="ui labels">
<slot></slot>
</div>
`
我想重写,这样我可以动态地设置模板的HTML标记 - 类似我做什么与此代码:
props: ['tag', 'attributes'],
render(createElement) {
return createElement(this.tag || 'div', {attrs: this.attributes || {}}, this.$slots.default);
}
不过,我想使用JSX语法 - 因为这里指出:https://vuejs.org/v2/guide/render-function.html#JSX
我想不通,但是,如何将这种使用JSX形式上做吨。
任何想法?
感谢
首先,你有没有[插件提到](https://github.com/vuejs/babel-plugin-transform-vue-jsx)? –
是的,我已经安装了该插件 – Moshe