vite-plugin-vue2-jsx icon indicating copy to clipboard operation
vite-plugin-vue2-jsx copied to clipboard

h function context not same as webpack, which is right?

Open defghy opened this issue 1 year ago • 2 comments

use render function to create customElement;

<template>
  <div :style="{ '--node-height': height + 'px' }" class="c-page">
    <VTree ref="vtree" class="constraint-tree" :render="renderNode" :nodeMinHeight="height" />
  </div>
</template>

    renderNode(node: any) {
      let compName = 'CNodeCommon'
      if (isArray) {
        compName = 'CNodeArray'
      }
      return <compName class="contraint-node" info={info} />
    },

webpack use vm.$createElement,context is this image

vite use h function, context is the ui-lib's component image

vite will show this error; Tried jsx in setup or methods both has same problem

 Unknown custom element: <CNodeCommon> - did you register the component correctly?

In my case, webpack is more reasonable, because I cannot controll ui lib's component vue-tree lib: https://github.com/wsfe/vue-tree

"vite": "^5.0.11",
"@vitejs/plugin-vue2": "^2.3.1",
"@vitejs/plugin-vue2-jsx": "^1.1.1",
"vue": "^2.7.16",

defghy avatar Jan 15 '24 10:01 defghy