ant-design-vue icon indicating copy to clipboard operation
ant-design-vue copied to clipboard

Console error message "xx.confirm is not a function" and not show dialog.

Open iwengx opened this issue 3 years ago • 9 comments
trafficstars

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.2.5

Environment

Vite^2.9.9、Vue^3.2.36、pnpm

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  1. Create a Vue project using the above environment.
  2. Using Confirmation modal dialog Example
  3. pnpm run build and click button.

What is expected?

Show a confirmation modal dialog.

What is actually happening?

Console error message "xx.confirm is not a function" and not show dialog.


In the build environment.

iwengx avatar Jun 30 '22 10:06 iwengx

Hello @wengx-unx. We totally like your proposal/feedback, welcome to send us a Pull Request for it. Please send your Pull Request to proper branch, fill the Pull Request Template here, provide changelog/TypeScript/documentation/test cases if needed and make sure CI passed, we will review it soon. We appreciate your effort in advance and looking forward to your contribution!

你好 @wengx-unx,我们完全同意你的提议/反馈,欢迎直接在此仓库创建一个 Pull Request 来解决这个问题。请将 Pull Request 发到正确的分支,务必填写 Pull Request 内的预设模板,提供改动所需相应的 changelog、TypeScript 定义、测试用例、文档等,并确保 CI 通过,我们会尽快进行 Review,提前感谢和期待您的贡献。

github-actions[bot] avatar Jul 01 '22 05:07 github-actions[bot]

Has this problem been fixed?

cshuting avatar Jul 06 '22 01:07 cshuting

Has this problem been fixed?

Not yet

iwengx avatar Jul 06 '22 01:07 iwengx

After verification, under the premise of the same environment, the pop-up window after construction can work normally. You can take a look at this example:

https://github.com/techbirds/my-vue-app

pnpm i
pnpm run serve

So please check whether your environment is normal and whether the writing method is correct.

techbirds avatar Jul 06 '22 03:07 techbirds

Has this problem been fixed?

Not yet

same problem, after builded the project with vite.

gitgundam avatar Jul 07 '22 07:07 gitgundam

you can try to use import Modal from "ant-design-vue/lib/modal" instead of import { Modal } from "ant-design-vue"

eisir avatar Jul 07 '22 08:07 eisir

you can try to use import Modal from "ant-design-vue/lib/modal" instead of import { Modal } from "ant-design-vue"

it worked

lxchapu avatar Jul 07 '22 08:07 lxchapu

the same

zch233 avatar Aug 22 '22 09:08 zch233

i have the same problem

peerlessXu avatar Sep 02 '22 07:09 peerlessXu

the same

wjkang avatar Oct 10 '22 08:10 wjkang

have any result

asiyuan avatar Oct 24 '22 07:10 asiyuan

you can try to use import Modal from "ant-design-vue/lib/modal" instead of import { Modal } from "ant-design-vue"

so use this, can't open in development

asiyuan avatar Oct 24 '22 07:10 asiyuan

you can try to use

// modal.ts
import { Modal } from 'ant-design-vue'
export const {  info, success, error, warning, confirm } = Modal
<!-- demo.vue -->
<template>
  <button @click="handleClick">click me</button>
</template>

<script  lang="ts">
import {confirm} from './modal'
export default {
  setup() {

    return {
      handleClick() {
       confirm({
          title: "title", 
          onOk() {
            console.log("hi...")
          }
        })
      }
    }
  }
}
</script>

I think this question should be in vite...

cn-wang avatar Dec 03 '22 08:12 cn-wang

you can try to use

// modal.ts
import { Modal } from 'ant-design-vue'
export const {  info, success, error, warning, confirm } = Modal
<!-- demo.vue -->
<template>
  <button @click="handleClick">click me</button>
</template>

<script  lang="ts">
import {confirm} from './modal'
export default {
  setup() {

    return {
      handleClick() {
       confirm({
          title: "title", 
          onOk() {
            console.log("hi...")
          }
        })
      }
    }
  }
}
</script>

I think this question should be in vite...

Tried the above solution, still does not work. Can confirm this question occurred in vite. However, importing from ant-design-vue/lib/modal works.

dodaydream avatar Dec 13 '22 02:12 dodaydream

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Feb 12 '23 02:02 github-actions[bot]

same problem

hakityc avatar Mar 29 '23 05:03 hakityc

- My solution is: I use confirm modal in package "ant-design-vue". I dont import all component, i import several component.

// important import { Modal } from "ant-design-vue"; Vue.prototype.$confirm = Modal.confirm;

thaotrong2000 avatar Mar 29 '23 10:03 thaotrong2000

same problem My solution: https://github.com/vueComponent/ant-design-vue/issues/5763#issuecomment-1488380170

thaotrong2000 avatar Mar 29 '23 10:03 thaotrong2000

Thanks! I have successed in his way (eisir )

hakityc avatar Mar 31 '23 06:03 hakityc

Thanks! I have successed in his way (eisir )

https://github.com/vueComponent/ant-design-vue/issues/5763#issuecomment-1177231433

hakityc avatar Mar 31 '23 06:03 hakityc

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Mar 31 '24 00:03 github-actions[bot]