Vue 3与Vue.extend()的等价物

mqkwyuun  于 7个月前  发布在  Vue.js
关注(0)|答案(1)|浏览(115)

我正在尝试将下一段代码从vue 2迁移到vue 3:Vue 2到vue 3选项API代码在3 party纯js库中使用的其他函数的回调中

const cls = Vue.extend(extendComponent);
 const instance = new cls({
      data: {
         obj: data,
         toolkit: toolkit,
         surface: surface,
         vertex: node
      },
      parent: parentComponent
                            
});
instance.$mount();

instance.$el._ref = instance;
return instance.$el;

字符串
有什么想法吗?提前谢谢!
我尝试过使用NodeVNode和definedComponent,但没有成功

w9apscun

w9apscun1#

解决方案是:

const el = document.createElement('div')
let vnode = createVNode({
        data: {
            obj: data,
            toolkit: toolkit,
            surface: surface,
            vertex: node
        },
        parent: toolkitComponent,
        extends: def.component })

const oel = render(vnode, el)

return vnode.el

字符串

相关问题