使用方法:
    h(标签, {属性},内容)
    h(标签, {属性},[可以继续嵌套h()])
    createVNode(标签, {属性},内容)
    createVNode(标签, {属性},[可以继续嵌套createVNode()])

    其实h()函数和createVNode()函数都是创建dom节点,他们的作用是一样的,但是在VUE3中createVNode()函数的功能比h()函数要多且做了性能优化,渲染节点的速度也更快。

    1. import { createApp } from "vue";
    2. //import App from "./App.vue";
    3. import { defineComponent, h, createVNode } from "vue";
    4. import HelloWorld from "./components/HelloWorld.vue";
    5. const img = require('./assets/logo.png'); // eslint-disable-line
    6. const App = defineComponent({
    7. render() {
    8. return h("div", { id: "app" }, [
    9. h("img", { src: img }),
    10. h(HelloWorld, { msg: "HelloWorld" }),
    11. createVNode("h1", { class: "hello" }, "HelloWorld")
    12. ]
    13. );
    14. },
    15. });
    16. createApp(App).mount("#app");

    渲染出来的结果为:
    image.png