A small wrapper for integrating SweetAlert to Vuejs
JavaScript Vue
Switch branches/tags
Nothing to show
Latest commit 824b5f9 Oct 7, 2017 @anteriovieira anteriovieira Doc updated
Permalink
Failed to load latest commit information.
build First commit Oct 3, 2017
media Doc updated Oct 7, 2017
src First commit Oct 3, 2017
test First commit Oct 3, 2017
.babelrc First commit Oct 3, 2017
.editorconfig First commit Oct 3, 2017
.eslintignore First commit Oct 3, 2017
.eslintrc.js First commit Oct 3, 2017
.gitignore First commit Oct 3, 2017
.stylelintrc First commit Oct 3, 2017
CONTRIBUTING.md First commit Oct 3, 2017
LICENSE First commit Oct 3, 2017
README.md Doc updated Oct 7, 2017
package-lock.json 0.0.4 Oct 4, 2017
package.json Doc updated Oct 4, 2017

README.md

VueSwal

npm vue2

You can customize VueSwal to fit your needs.

Api sweetalert or Examples

Installation

npm

npm install vue-swal

yarn

yarn add vue-swal

Usage

Bundler (Webpack, Rollup)

import Vue from 'vue'
import VueSwal from 'vue-swal'

Vue.use(VueSwal)

Browser

<!-- Include after Vue -->
<!-- Local files -->
<script src="vue-swal/dist/vue-swal.js"></script>

<!-- From CDN -->
<script src="https://unpkg.com/vue-swal"></script>

Simply happens

export default {
  methods: {
    alert() {
      this.$swal('Hello word!')
    }
  }
}

Examples

Basic Example Advanced Example
basic example advanced example

Using Nuxt.js

Using the plugin with nuxt is really very simple.

Add file plugins/vue-swal.js:

import Vue from 'vue'
import VueSwal from 'vue-swal'

Vue.use(VueSwal)

Then, we add the file inside the plugins key of nuxt.config.js:

module.exports = {
  plugins: ['~/plugins/vue-swal']
}

To learn more about the plugins configuration key, check out the plugins api.

The, vue-swal will be included in the app bundle, but because it's a library, we want to include it in the vendor bundle for better caching.

We can update our nuxt.config.js to add vue-swal in the vendor bundle:

module.exports = {
  build: {
    vendor: ['vue-swal']
  },
  plugins: ['~/plugins/vue-swal']
}

Click here to see a complete example.

License

MIT