Comments (10)
@avil13 thank you very much for your awesome work. 🙂
I would love to know how can we create mixins using your plugin. The official documentation says the following: " You can easily reuse configuration by creating your own Swal
with Swal.mixin({ ...options }):
"
However, not sure how can we create them and execute them globally.
Really thank you and keep the good work 😄
from vue-sweetalert2.
You may need to create a plugin for Nuxt.
Check out the Nuxt documentation for this. Right now I can not help you, but it is possible.
from vue-sweetalert2.
This could also be handy for Vue. Like doing the classic:
import Vue from 'vue'
import VueSweetalert2 from 'vue-sweetalert2'
const globalOptions = {
confirmbuttonColor: red;
}
Vue.use(VueSweetalert2, globalOptions)
Want to create a pull request for this, but my experience in creating Vue bindings is too limited.
from vue-sweetalert2.
I had an idea for generating mixins in a similar way.
But he didn’t do it, because it’s not clear whether the developer needs it.
Now there is a clean wrap over Sweetalert2.
You can try to add this API.
If it is useful, then add to the master branch.
from vue-sweetalert2.
Created a pull request with Nuxt options and Vue options for global defaults. I didn't update ts definitions, because I don't know typescript. @avil13 can you review and merge?
from vue-sweetalert2.
Thanks for the pull request.
Had the idea to change it a bit. I want to consult.
this.$swal
- this is a common function for creating the alert.
What if given the opportunity to create several prepared alert
or toast
messages?
const options = {
mixins: {
// key for alert
goodAlert: {
type: 'success',
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000
}
}
};
Vue.use(VueSweetalert2, options);
// use in vue component
export default {
methods: {
alert() {
// key for alert
this.$swal.goodAlert('Hello world');
}
}
}
from vue-sweetalert2.
My first thought was that passing global options only is better because you usually end up requiring some minor details to change anyway and end up having a set of standard messages that you don't use. On the other hand, for some use cases it would be better to have a set of standard alerts ready. I am not sure. Maybe try the simple one first and add more complexity if other people ask for the second feature? The pull request I created covers my personal use case.
from vue-sweetalert2.
I apologize for such a long wait for merge.
#39
from vue-sweetalert2.
Please, document this !
from vue-sweetalert2.
Thanks for the pull request.
Had the idea to change it a bit. I want to consult.
this.$swal
- this is a common function for creating the alert.What if given the opportunity to create several prepared
alert
ortoast
messages?const options = { mixins: { // key for alert goodAlert: { type: 'success', toast: true, position: 'top-end', showConfirmButton: false, timer: 3000 } } }; Vue.use(VueSweetalert2, options);// use in vue component export default { methods: { alert() { // key for alert this.$swal.goodAlert('Hello world'); } } }
Is this ideia working? I'm trying to implement and it says:
SweetAlert2: Unknown parameter "mixins"
from vue-sweetalert2.
Related Issues (20)
- How is the best method to updating Swal in Laravel Project? HOT 2
- [Nuxt] Support top level option HOT 2
- Module display flex instead of grid HOT 9
- No release for v5.0.0, 5.0.1 and 5.0.2 on Github HOT 4
- Wrong CSS HOT 4
- Is this compatible with Nuxt3? HOT 2
- Vue3,在 setup 中无法使用,希望可以兼容一下 Vue3 的新语法 HOT 4
- Style not applied in Nuxtjs 2 HOT 6
- Inertiajs: Cannot read properties of undefined (reading '$swal') HOT 4
- How to use in setup method? HOT 1
- Security issue on SweetAlert2 HOT 5
- When installing package its output : ERROR Cannot restart nuxt: Cannot read properties of undefined (reading 'sweetalert') HOT 10
- ERROR Cannot restart nuxt: Cannot read properties of undefined (reading 'sweetalert') HOT 2
- Emit not being triggered within sweetalert once deployed HOT 1
- Does not work on devices running iOS 15 lower
- this.$swal not work in VueJS 3 (script setup) HOT 2
- Failed to resolve entry for package "vue-sweetalert2". The package may have incorrect main/module/exports specified in its package.json HOT 8
- Failed to resolve entry for package "vue-sweetalert2". The package may have incorrect main/module/exports specified in its package.json. HOT 1
- Module import VueSweetalert2 from 'vue-sweetalert2' not found in main.js HOT 1
- Nuxt project build failed with: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './nuxt' is not defined by "exports" in vue-sweetalert2\package.json HOT 10
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-sweetalert2.