【发布时间】:2017-10-16 03:17:18
【问题描述】:
我有以下 VueJS 组件:
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 格式来做到这一点。
有什么想法吗?
谢谢
【问题讨论】:
-
首先,你有plugin mentioned吗?
-
是的,我已经安装了那个插件
标签: vue.js vuejs2 jsx vue-component