primefaces / primevue

Next Generation Vue UI Component Library
https://primevue.org
MIT License
10.58k stars 1.23k forks source link

Toast: can't auto-import it #5922

Open cadilhac opened 4 months ago

cadilhac commented 4 months ago

Describe the bug

I have a Toast tag in the higher level template vue file. If I add this in the file:

import Toast from 'primevue/toast'

Then toasting works well.

But if I remove it, it doesn't. However, I have auto-import configured in main.js and it works well for the other components I'm using.

Reproducer

not available

PrimeVue version

3.52.0

Vue version

3.x

Language

ALL

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

Primevue should also auto-import the Toast component.

SzymCode commented 4 months ago

@cadilhac You probably didn't import & use ToastService

Example solution:

import { createApp } from 'vue';
import PrimeVue from 'primevue/config';
import ToastService from 'primevue/toastservice';

export const app = createApp({});

app.use(PrimeVue).use(ToastService).mount('#app');

Did you use useToast like this?

import { useToast } from 'primevue/usetoast';

const toast = useToast();
cadilhac commented 4 months ago

Yes, I followed the doc and imported ToastService and wrote the same code as you.

On components where I have to use the toast object, yes, I imported useToast like this. On the top component, I simply put Toast in the template and import nothing, hoping that the auto-import will do its job. But it does not work, so I have to import Toast.