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

Vue3 加载报错 TypeError: Cannot read properties of undefined (reading 'add') 版本: "view-ui-plus": "^1.3.16", #361

Open
cy08 opened this issue Apr 18, 2024 · 1 comment

Comments

@cy08
Copy link

cy08 commented Apr 18, 2024

main.js
`
import { createApp } from 'vue'
import App from '@/App.vue'
import ViewUIPlus from 'view-ui-plus'

const app = createApp(App);
app.provide('Message', ViewUIPlus.Message);
app.mount('#app');
`

index.js
`
import { ref, inject, reactive, watch, computed, onMounted } from "vue";
const Message = inject("Message");

nMounted(async () => {

Message.loading({
content: "加载中...",
duration: 0,
});
})
`

出现错误

view-ui-plus.js?v=1bd0da6a:10103 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'add') at Object.notice (view-ui-plus.js?v=1bd0da6a:10103:13) at a0 (view-ui-plus.js?v=1bd0da6a:10123:18) at Object.message (view-ui-plus.js?v=1bd0da6a:10146:62) at Object.error (view-ui-plus.js?v=1bd0da6a:10142:21) at onSearch (index.vue:680:13) at index.vue:401:5 at chunk-XGACGZPK.js?v=6e19c5a1:7673:92 at callWithErrorHandling (chunk-XGACGZPK.js?v=6e19c5a1:1722:18) at callWithAsyncErrorHandling (chunk-XGACGZPK.js?v=6e19c5a1:1730:17) at hook.__weh.hook.__weh (chunk-XGACGZPK.js?v=6e19c5a1:3467:19)

请问大佬这需要怎么解决

@h3clikejava
Copy link

h3clikejava commented May 31, 2024

在onMounted里面不能用Message,估计是控件还没初始化。放到后面的逻辑里就可以。

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

2 participants