use functional component

This commit is contained in:
Philipp Kühn
2020-11-19 10:36:06 +01:00
parent 967a82b375
commit 2d2ffb60ef
2 changed files with 14 additions and 4 deletions

View File

@@ -7,7 +7,8 @@
<component :is="inner" /> <component :is="inner" />
<inner /> <inner />
</div> --> </div> -->
<inner /> <inner as="p" class="hey" foo="bar" />
<!-- <component :is="inner" as="p" /> -->
</template> </template>
<script> <script>

View File

@@ -38,16 +38,25 @@ class VueNodeView implements NodeView {
mount(component: Vue | VueConstructor) { mount(component: Vue | VueConstructor) {
this.id = `id_${Math.random().toString(36).replace('0.', '')}` this.id = `id_${Math.random().toString(36).replace('0.', '')}`
const { id } = this
const Inner = Vue.extend({ const Inner = Vue.extend({
functional: true, functional: true,
render: createElement => { // inheritAttrs: false,
props: {
as: {
type: String,
default: 'div',
},
},
render(createElement, context) {
return createElement( return createElement(
'div', { context.props.as, {
style: { style: {
whiteSpace: 'pre-wrap', whiteSpace: 'pre-wrap',
}, },
attrs: { attrs: {
id: this.id, id,
}, },
}, },
) )