Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App包裹组件 在 pinia 全局场景 中 App.useApp() 返回的 message notification modal 等为空 #7931

Open
1 task done
puzzle9 opened this issue Nov 13, 2024 · 5 comments

Comments

@puzzle9
Copy link

puzzle9 commented Nov 13, 2024

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

Version

4.2.6

Environment

vue 3.5.12

Reproduction link

Edit on CodeSandbox

Steps to reproduce

app.vue

<template>
app
<br />
<a-config-provider :locale="zhCN">
<a-app>
<router-view />
</a-app>
</a-config-provider>
</template>

<script setup>
import zhCN from "ant-design-vue/es/locale/zh_CN";
</script>

index.vue

<template>
index

<br />

<a-button @click="addd">点我看提示</a-button>
</template>

<script setup>
import { useGlobalStore } from "./pinia";
const global = useGlobalStore();

console.log(global);

const addd = () => {
console.log(global.message);
console.log(global.message.info("infoa"));
};
</script>

pinia

import { App } from "ant-design-vue";
import { defineStore } from "pinia";
import { ref } from "vue";

export const useGlobalStore = defineStore("global", () => {
const message = ref();
const notification = ref();
const modal = ref();
(() => {
const staticFunction = App.useApp();
message.value = staticFunction.message;
modal.value = staticFunction.modal;
notification.value = staticFunction.notification;
})();

return { message, notification, modal };
});

What is expected?

可以弹出 message 提示

What is actually happening?

global.message.info is not a function

index.vue

14 |
15 | const addd = () => {
16 |   console.log(global.message);
> 17 |   console.log(global.message.info("infoa"));
|                             ^
18 | };
19 | </script>
20 |
@WeylinRG
Copy link

I have the same issue

@zguiyang
Copy link

zguiyang commented Dec 6, 2024

+1

@974869973
Copy link

  • 10086

@muchengdong
Copy link

muchengdong commented Feb 12, 2025

@puzzle9 解决了吗

@puzzle9
Copy link
Author

puzzle9 commented Feb 13, 2025

@puzzle9 解决了吗

没有 我换框架了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants