Comments (3)
@steakscience Since the answers above didn't help me. I did it this way:
Import your component anyway at the top of your plugin or vue file
import Toast from '../components/toasts/Importing.vue'
And then pass it as the first param when calling
$toast = $nuxt.$toast.info(Toast)
Hope it helps
from vue-sonner.
If I understand your question correctly, Nuxt autoloads components so you can just follow the install guide and then in your App.vue...
`
<button @click="() => toast('My first toast')">Render a toast
This should work.
from vue-sonner.
If you have followed Sonner's setup instructions, you may have created a plugins/sonner.client.ts
file to add the Toaster
component globally. The word client
in the filename signifies that the component is meant to be rendered exclusively on the client side. Yet, when the Toaster
is used within a .vue
SFC, the server attempts to render it as well, leading to an error since theToaster
is configured to render on the client-side only.
To resolve this issue, enclose Toaster
component within a <ClientOnly>
. This ensures that the Toaster
is rendered only on the client side.
Your code would then look like the following:
<!-- App.vue -->
<template>
<!-- existing content -->
<ClientOnly>
<Toaster />
</ClientOnly>
<button @click="() => toast('My first toast')">
Give me a toast
</button>
</template>
from vue-sonner.
Related Issues (20)
- Toast with type action don't work on mobile HOT 1
- Can we pass the prop on headless toast for title and description? HOT 1
- Toasts with action `freeze` when you hit fast on the action buttons HOT 2
- Extending Not working correctly HOT 2
- Add "classNames" props HOT 1
- Swipeable sonner HOT 1
- custom component - option to keep style HOT 1
- Possible bugs when using fixed
- can we dismiss the toast programmatically? `toast.dismiss()` does not work HOT 11
- Why so many issues for such as simple plugin? HOT 5
- Global config HOT 1
- Persitent accross layouts in Nuxt 3 HOT 4
- [Bug]: error on hitting `Esc` button
- Error: when pressing ESC key HOT 2
- Bug: Can't create new toasts after dismiss HOT 4
- Everything is deleted after <Toaster />, and sometimes the toast() function works, sometimes not HOT 4
- remove inline-styles to pass CSP
- ERROR - Dismiss not working HOT 3
- Dynamic Positioning not working HOT 3
- Allow specifying attributes on wrapper `<section>`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-sonner.