1
i use antd vue model to create a confirm modal,and use createVNode for my content
 const modalRef = Modal.confirm({
     content: createVNode(CategoryTreeAddModal),
     centered: true,
     icon: undefined,
     onCancel: (event) => {
       console.log(CategoryTreeAddModal)
       // modalRef.destroy();
     },
     onOk: (event) => {
       console.log(CategoryTreeAddModal)
       // modalRef.destroy();
     }
   })

这是我的内容代码

<template>
 <a-form ref="formRef" :model="formState" :rules="rules" class="login-form">
   <a-form-item ref="name" name="name">
     <a-input v-model:value="formState.name" placeholder="请输入名称&quot; />
   </a-form-item>
 </a-form>
</template>

它只是警告我无法解析组件:a-input a-form-item a-form,如何解决,我只是想用这种方式来创建我的确认模式

4

1 回答 1

0

你可以试试这个

 const instalce = getCurrentInstance()
 const vnode = createVNode(CategoryTreeAddModal)
 vnode.appContext = instance.appContext
 const modalRef = Modal.confirm({
     content: vnode,
     centered: true,
     icon: undefined,
     onCancel: (event) => {
       console.log(CategoryTreeAddModal)
       // modalRef.destroy();
     },
     onOk: (event) => {
       console.log(CategoryTreeAddModal)
       // modalRef.destroy();
     }
   })
于 2021-09-23T09:16:30.147 回答