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" />
<inner />
</div> -->
<inner />
<inner as="p" class="hey" foo="bar" />
<!-- <component :is="inner" as="p" /> -->
</template>
<script>

View File

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