use functional component
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user