Using VNodes in the template.
npm i @vasiliyrusin/v-node
import Vue from "vue";
import VNode from "@vasiliyrusin/v-node";
Vue.use(VNode);
import { VNode } from "@vasiliyrusin/v-node";
export default {
name: "ComponentName",
components: { VNode }
}
<template>
<VNode :node="exampleJSX"></VNode>
<VNode :node="exampleCreateElement"></VNode>
<VNode :node="exampleCreateElementHack"></VNode>
</template>
<script>
import { VNode } from "@vasiliyrusin/v-node";
export default {
name: "ExampleComponent",
components: { VNode },
computed: {
exampleJSX () {
return (<h1>Hello world!</h1>);
},
exampleCreateElement () {
return this.$createElement("h1", "Hello world!");
},
// Not recommended to use it
exampleCreateElementHack () {
return [
this.$createElement("h1", "Hello world!"),
this.$createElement("h1", "Hello world!")
];
}
}
}
</script>