Coder Social home page Coder Social logo

avil13 / vue-sweetalert2 Goto Github PK

View Code? Open in Web Editor NEW
636.0 8.0 74.0 3.95 MB

A convenient wrapper for sweetalert2.

Home Page: https://avil13.github.io/vue-sweetalert2/

JavaScript 11.30% TypeScript 38.93% Shell 4.53% HTML 4.17% Vue 14.35% CSS 26.71%
sweetalert vue vue-sweetalert2 alert javascript ssr

vue-sweetalert2's Introduction

vue-sweetalert2

npm

Coverage Status

Vue.js wrapper for SweetAlert2. With support SSR.

changelog


Attention:

When using "Vue3: Composition API" it is better not to use this wrapper. It is more practical to call sweetalert2 directly.

Also, it is better to do it to get feedback faster, and be closer to the documentation.


VueSweetalert2

vue-sweetalert2 demo


Get started

Basics

Bash

npm install -S vue-sweetalert2

Add types to TypeScript project

{
  //...tsconfig.json
  "types": [
    "vue-sweetalert2"
  ],
}

vue 2

// main.js
import Vue from 'vue';
import VueSweetalert2 from 'vue-sweetalert2';

// If you don't need the styles, do not connect
import 'sweetalert2/dist/sweetalert2.min.css';

Vue.use(VueSweetalert2);

vue 3

// main.js
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'

import VueSweetalert2 from 'vue-sweetalert2';
import 'sweetalert2/dist/sweetalert2.min.css';

const app = createApp(App)

app.use(VueSweetalert2);

app.mount('#app');

Now in the global object, you can access all the methods of sweetalert2.

// example-vue-component.vue
<template>
  <button @click="showAlert">Hello world</button>
</template>

<script>
export default {
  methods: {
    showAlert() {
      // Use sweetalert2
      this.$swal('Hello Vue world!!!');
    },
  },
};
</script>

// Or

Vue.swal('Hello Vue world!!!');

Global options

If you want to add global options like button colors, do something like this:

// main.js
import Vue from 'vue';
import VueSweetalert2 from 'vue-sweetalert2';

const options = {
  confirmButtonColor: '#41b882',
  cancelButtonColor: '#ff7674',
};

Vue.use(VueSweetalert2, options);

Custom styling

Using scss styles are loaded so

// main.js
import Vue from 'vue';
import VueSweetalert2 from 'vue-sweetalert2';

Vue.use(VueSweetalert2);
// style.scss
@import '~sweetalert2/src/variables';

$swal2-background: #990000;

@import '~sweetalert2/src/sweetalert2';

Nuxt.js

Install dependencies:

npm install -S vue-sweetalert2

Add vue-sweetalert2/nuxt to modules section of nuxt.config.js

{
  modules: ['vue-sweetalert2/nuxt'];
}

Or pass in global options like this:

{
  modules: [
    'vue-sweetalert2/nuxt',
  ],
  sweetalert: {
    confirmButtonColor: '#41b882',
    cancelButtonColor: '#ff7674'
  }
}

Using a different theme in Nuxt

Add vue-sweetalert2/nuxt to modules section of nuxt.config.js

{
  // Before doing so, install the "@sweetalert2/theme-dark"
  css:     [ '@sweetalert2/theme-dark' ],
  modules: ['vue-sweetalert2/nuxt/no-css'];
}

The documentation for sweetalert2, you can find here.

vue-sweetalert2's People

Contributors

avil13 avatar bowens20832 avatar camaech avatar dependabot[bot] avatar dids avatar effe-ickx avatar greenkeeper[bot] avatar hoshinoas avatar imrec avatar limonte avatar mrleblanc101 avatar mul14 avatar omletina avatar rekryt avatar ricardogobbosouza avatar rmaharba avatar thedarkita avatar vincentdh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-sweetalert2's Issues

Some object properties not working?

So this works fine:
this.$swal("Good job!", "You clicked the button!", "success")

However as soon as I use an object some properties do not work:
this.$swal({ title: "Good job!", text: "You clicked the button!"", icon: "success", });
In this case only the icon property didn't work. I have also had the same issue with buttons e.g. false and text.

Error when importing

Why I can't use this plugin?
It has error while importing.
Im using browserify with vueify
screen shot 2019-02-19 at 10 21 59 am
screen shot 2019-02-19 at 10 24 05 am

I also check the files on this plugin upon installing, but it has only few files.
screen shot 2019-02-19 at 10 23 18 am

Ghost version 2.1.1 on npm

Hey,

I have been using vue-sweetalert2 for quite sometime now. Before I update all my dependencies, I always do my due diligence to check what has changed in the new version.

I just got an alert for vue-sweetalert2 2.1.1. Naturally, I came here to check what has changed but the last commit was 5 days ago for 2.1.0.

This is obviously a red flag for me. I did check the code a bit and noticed a few changes in the dist folder (Nothing malicious)

Where did 2.1.1 come from? What was added/removed/changed?

I did notice the file size decreased slightly in 2.1.1.

Question: Is there a way to inject defaults somewhere?

Apologies for the last question, apparently it was not that self-explanatory. I am using a nuxt app. Can I pass global config for swal somewhere? I am trying $swal.mixin in numerous locations, but to no avail. Preferably would want to do this on server init or via nuxt.config.js.

Typescript Error - Cannot use namespace 'swal' as a type

Error received:

ERROR in c:/Users/my-name/workspace/Apps/Client/node_modules/vue-sweetalert2/src/index.d.ts
6:25 Cannot use namespace 'swal' as a type.
4 | // declare function swal(title: string, message?: string, type?: SweetAlertType): Promise;
5 |

6 | declare type swalFunc = swal;
| ^
7 |
8 | declare module 'vue/types/vue' {
9 | interface Vue {
ERROR in c:/Users/my-name/workspace/Apps/Client/node_modules/vue-sweetalert2/src/index.d.ts
10:16 Cannot use namespace 'swal' as a type.
8 | declare module 'vue/types/vue' {
9 | interface Vue {
10 | $swal: swal; // () => Promise;
| ^
11 | }
12 | }
13 |
ERROR in c:/Users/my-name/workspace/Apps/Client/node_modules/vue-sweetalert2/src/index.d.ts
16:16 Cannot use namespace 'swal' as a type.
14 | declare module 'vue/types/options' {
15 | interface ComponentOptions {
16 | swal?: swal; // () => Promise;
| ^
17 | }
18 | }

Steps taken:

  1. yard add vue-sweetalert2
  2. main.ts -> added the following:
    import VueSweetalert2 from "vue-sweetalert2";
    Vue.use(VueSweetalert2);

As soon as I save, the vue cli compiles and spits out the errors provided above.

I'm using version: "vue-sweetalert2": "^1.5.6"

Thank you for your time and consideration.

helllo

screen shot 2018-08-26 at 15 08 30

hello i tried using sweetalert2 in the vue with typescript project but there was an error
I don't know why
Here I attach an error that was obtained

showLoading

this.$swal({
            title: '<strong>HTML <u>example</u></strong>',
            type: 'info',
            timer: 2000,
            onBeforeOpen: () => {
                this.$swal.showLoading()
            },
            showCloseButton: false,
            showCancelButton: false,
        })

this.$swal.showLoading() is not working

Cannot resolve vue-sweetalert2/nuxt

Hello.
I am trying to use this package with nuxt, but after I followed the instruction from the readme I get the following error

fatal Error: Cannot resolve "vue-sweetalert2/nuxt"

I looked in node_modules/vue-sweetalerts2 and I see that there is no nuxt folder in there. Am I missing something?
the support for nuxt is not released yet?

TypeError: t.forEach is not a function

Hi there,

I just installed the packaged and wanted to make it use Bootstrap styling as per shown in the SweetAlert2 documentations.
I've got this so far but get an error :
TypeError: t.forEach is not a function when calling this.$swal('Hello');

Here is how I setup VueSweetAlert2:

import Vue from 'vue';
import VueSweetalert2 from 'vue-sweetalert2';

Vue.use(VueSweetalert2, {
    customClass: {
        confirmButton: 'btn btn-sm btn-success',
        cancelButton: 'btn btn-sm btn-danger'
    },
    buttonsStyling: false,
});

Any idea what I am doing wrong ?

Thanks

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

`toast`s are blocking page

Hi,

I have problem manipulating toast option on vue-sweetalert2 version 1.5.9 which causes entire page to be blocked until timeout is reached. Here is a simple config:

this.$swal({
	toast: true,
	position: 'top-end',
	showConfirmButton: false,
	timer: 10000,
	type: 'success',
 	text: 'Sorry, you have no choice but to wait 10 seconds!',
});

Compare the behaviour with the original Sweetalert2 pen in which is non-blocking:

https://codepen.io/amirrezanasiri/pen/RqYyqN

Please let me know if I should give anything else about the problem I face.

vue-sweetalert2/nuxt

I'm having this problem with vue-sweetalert2/nuxt
Error:
this.$swal is not a function

index.vue --> mounted()...
this.$swal('Hello word!')

Page doesn't load above version 1.5.2 on Ipad Air 2

There is problem on Ipad Air 2 above version 1.5.2 (maybe high). Demo page loads but alerts don't show up. I tested on browserstack. When I create project with sweetalert2 and vuetify then the page don't load. I have error in my console (of course after building):

SyntaxError: Unexpected token '('. Expected a ':' following the property name 'measurableStyles'.

Did anyone have a similar issue?

Alerts aren't truly "modal"

If I use vanilla alert() with async code, they will stack and I get to see all errors. If another swal is fired while one is displayed, the old one is simply replaced and I don't get to see the first error message. Is there a workaround for this behavior?

cannot get swal parameters (l title, content , message ,..) in test:unit of my component

testing my component , I mocked a swal in my spec file:

 it("should validate the form and send the message", async () => {
    // given
    const mockSwal = Vue.swal(
      {
        title: "atitle",
        text: "a success message",
        type: "error",
        customClass: "swalalert",
        confirmButtonText: "OK"
      },
      function() {
        this.$store.dispatch("switchLoading", false);
        router.push("/home");
      }
    );
    const contactAxiosUrl = process.env.VUE_APP_AXIOS_URL + "newContactMessage";
    http
      .onPost(contactAxiosUrl)
      .reply(200, {});
    store = new Vuex.Store({
      state: {
        language: "en",
        loading: false
      },
      actions: {
        switchLoading: jest.fn()
      }
    });
    options = {
      sync: false,
      provide: {
        $validator() {
          return new VeeValidate.Validator();
        },
        $swal() {
          return mockSwal
        }
      },
      i18n,
      store
    };
    wrapper = mount(ContactForm, options);
    const contactForm = wrapper.find("form");
    // when
    const radioInput = wrapper.findAll('input[type="radio"]');
    radioInput.at(1).setChecked(); // input element value is changed, v-model is not
    radioInput.at(1).trigger("change"); // v-model updated

    input = wrapper.find('input[name="givenName"]');
    input.element.value = "John"; // input element value is changed, v-model is not
    input.trigger("input"); // v-model updated

    input = wrapper.find('input[name="familyName"]');
    input.element.value = "Doe"; // input element value is changed, v-model is not
    input.trigger("input"); // v-model updated

    input = wrapper.find('input[name="email"]');
    input.element.value = "[email protected]"; // input element value is changed, v-model is not
    input.trigger("input"); // v-model updated

    input = wrapper.find('textarea[name="messageContent"]');
    input.element.value = "Hello World!"; // input element value is changed, v-model is not
    input.trigger("input"); // v-model updated

    contactForm.trigger("submit");
    await wrapper.vm.$nextTick();
    console.log("SWAL: ", wrapper.vm.$swal.isVisible());
    const swalalert = wrapper.find('.swalalert');
    console.log("swalalert: ", swalalert.html());
    // then
    /*
    setTimeout(() => {
      expect(wrapper.vm.validForm).toEqual(false);
      console.log("done");
    }, 2000);
    */
  });

console output:
console.log("SWAL: ", wrapper.vm.$swal.isVisible()); => . true
but . const swalalert = wrapper.find('.swalalert'); raise an error , the custom class ..swalalert cannot be found in the DOM..

I tried also to get the swal title

console;log("TITLE: ", wrapper.vm.-swal.getTitle();
and it gives me:

TITLE:  HTMLHeadingElement {
  [Symbol(SameObject caches)]:
   { style:
      CSSStyleDeclaration {
        '0': 'display',
        _values: [Object],
        _importants: [Object],
        _length: 1,
        _onChange: [Function] } } }

it shoudl give me back the title I set in the mockSwal: "atitle"..

I guess I am missing something important in trying to mock the $swal ....

cannot be unit:tested ...

As per the doc , in my main.js , I import and use the plugin..

import VueSweetalert2 from "vue-sweetalert2";
Vue.use(VueSweetalert2);

In my component, ContactForm.vue, II can use:

this.$swal(...)

However , when I test:unit this component , I need to add the import and Vue.use()

  import VueSweetalert2 from "vue-sweetalert2";
 Vue.use(VueSweetalert2);

and I get an error:

	$ vue-cli-service test:unit ContactForm.spec.js
 FAIL  tests/unit/ContactForm.spec.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/yves/Developments/WIP/VUE.JS-cli-3/3-chocha-home-content/chocha/node_modules/vue-sweetalert2/src/index.js:2
    import swal from 'sweetalert2/dist/sweetalert2.min.js';
    ^^^^^^

    SyntaxError: Unexpected token import

whats wrong ?

Custom CSS

I'd like to use a custom theme for sweetalert2, but you are importing sweetalert2.min.css straight from the sweetalert2 package.

Anyway you could add a parameter such as this:
Vue.use(VueSweetalert2, {includeCss: false});

That way I could use webpack to compile sweetalert2 from source and override any variables that I want.

What convenience does this wrapper offer?

What convenience does this wrapper offer? What problem does it solve, or what does it make easier?

For the example in the README, why not just this?... Without the wrapper...

<template>
    <button v-on:click="showAlert">Hello world</button>
</template>

<script>
import swal from 'sweetalert2'
export default {
    data() {
        return {};
    },
    methods: {
        showAlert(){
            // Use sweetalret2
            swal('Hello Vue world!!!');
        }
    }
}
</script>

I think being an integration/wrapper for sweetalert2 with Vue does not automatically mean that it is something useful.

Whatever convenience this adds, I think the description should say it, because it isn't clear.

If this package does not help significantly, then it is actually hurting, because it includes sweetalert2 as it's own dependency and so, unless a new version of this is released for every new version of the core library, (1) users will almost always be forced to use a less-than-current version of sweetalert2, and (b) users will not be able to pin their dependency at any given version of sweetalert2.

How to use when passing options?

We can

this.$swal('Hello Vue world!!!');

But how can we pass, for example this ?

{ toast: true } 

I tried manually using the .fire() method

this.$swal.fire({
            title: this.title,
            type: this.type,
            toast: true
});

but

this.$swal.fire is not a function

Custom Styles not working after update

I previously used confirmButtonClass which worked before and not working after the update.

const options = {
	buttonsStyling: false,
	confirmButtonClass: 'btn white-text error',
	cancelButtonClass: 'btn white-text success'
}
Vue.use(VueSweetalert2, options)

I also tried this but still not working:

const options = {
	customClass: {
		confirmButton: 'v-btn white--text success',
		cancelButton: 'v-btn white--text error',
	},
	buttonsStyling: false,
}
Vue.use(VueSweetalert2, options)

What is the issue after update? am i missing something?

Latest version breaks my app

Hey guys
Thanks for your hard work with this.
Just so you know, I used Vue Sweetalert2 on another app and worked fine in IE11, it was version 1.4.2.
I just recently installed 1.5.0 in a new application and it would not working in IE11, even with Babel Polyfill.

The error was specifically because of this extra code:

Line 10 of index.js,

From VueSweetalert2.install = function(Vue) {

To VueSweetalert2.install = function(Vue, options = { toast: false }) {

I had to downgrade to 1.4.2 for it to work again, is there some sort of extra polyfill we need for this to work?
Cheers

Could not find a declaration file for module 'sweetalert2/dist/sweetalert2.min.js'

I have this error, how to solve ?

ERROR in /home/erick/git-projects/arquigames-cubes/node_modules/vue-sweetalert2/dist/index.d.ts
3:18 Could not find a declaration file for module 'sweetalert2/dist/sweetalert2.min.js'. '/home/erick/git-projects/arquigames-cubes/node_modules/sweetalert2/dist/sweetalert2.min.js' implicitly has an 'any' type.
Try npm install @types/sweetalert2 if it exists or add a new declaration (.d.ts) file containing declare module 'sweetalert2/dist/sweetalert2.min.js';
1 | import Vue from 'vue';
2 | import { SweetAlertOptions } from 'sweetalert2';

3 | import Swal from 'sweetalert2/dist/sweetalert2.min.js';
| ^
4 | declare type VueSwalInstance = typeof Swal.fire;
5 | declare module 'vue/types/vue' {
6 | interface Vue {
Version: typescript 3.5.2
Time: 5688ms

Method isVisisble() return always false in version 2.1.1

I updated the vue-sweetalert2 package from version 1.6.4 to version 2.1.1 and the method isVisible() not works in my unit tests.

Code example:

it('EventBus: errors.getFeaturesTeams', async () => {
    wrapper = shallowfactory({ loading: true }, { store, stubs: { vDatePicker, vBootstrapSelect } })
    Utils.EventBus.$emit(errors.getFeaturesTeams, 'Erreur de test unitaire')
    await wrapper.vm.$nextTick()
    expect(wrapper.vm.$swal.getTitle().innerHTML).to.eq('Récupération Echoué')
    expect(wrapper.vm.$swal.isVisible()).to.eq(true) <-- return false
    expect(wrapper.vm.$data.loading).to.eq(false) 
  })

It's code snippet had working correctly with version 1.6.4.

Anyone have idea fro what's happen ?

Amazon Web Services?

It seems this npm package has an indirect dependencie to amazon web services (aws4) I am confused has to why this is? Discard this issue if I was wrong, but it has me worried and I consequently decided against using it because of that.

Am I being paranoid?

Error : __WEBPACK_IMPORTED_MODULE_3_vue_sweetalert2__.a.queue is not a function

trying to test one the examples in my Vue component Profile.vue , i get an error

Profile.vue

`const ipAPI = 'https://api.ipify.org?format=json'
  swal.queue([{
    title: 'Your public IP',
    confirmButtonText: 'Show my public IP',
    text:
      'Your public IP will be received ' +
      'via AJAX request',
    showLoaderOnConfirm: true,
    preConfirm: () => {
      return fetch(ipAPI)
        .then(response => response.json())
        .then(data => swal.insertQueueStep(data.ip))
        .catch(() => {
          swal.insertQueueStep({
            type: 'error',
            title: 'Unable to get your public IP'
          })
        })
    }
  }])`

console.log

`Profile.vue?5da6:123 Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_3_vue_sweetalert2__.a.queue is not a function
at VueComponent.editPhotoUrl (eval at ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"/Users/myproject/node_modules/.cache/cache-loader"}!./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/Member/Profile.vue`

Unexpected token import

I try to use vue-sweetalert2 in my project:

import VueSweetalert2 from 'vue-sweetalert2';
Vue.use(VueSweetalert2);

But i recieve this error:

\node_modules\vue-sweetalert2\src\index.js:3 Uncaught SyntaxError: Unexpected token import
    at createScript (vm.js:80)
    at Object.runInThisContext (vm.js:139)
    at Module._compile (module.js:606)
    at Object.Module._extensions..js (module.js:653)
    at Module.load (module.js:561)
    at tryModuleLoad (module.js:504)
    at Function.Module._load (module.js:496)
    at Module.require (module.js:586)
    at require (internal/module.js:11)
    at eval (external "vue-sweetalert2"?cfeb:1)

Sweetalert in IE 10

I am using Sweetalert2 and it works perfectly in Chrome, Edge, IE 11 but IE 10. The problem is that when I try to open the pop-up window, it hides the pop-up window but also freezes everything! The screen user will not be able to click anywhere the page!

Object doesn't support property or method 'mixin'

Hey,

we included this plugin and having issues because of Swal is undefined in IE10.

Could we integrate a check if Swal is defined before using methods on it? Thanks.

const _swal = options ? Swal.mixin(options).fire.bind(Swal) : Swal.fire.bind(Swal);

vue-sweetalert2 in electron/vue app

Hi All,
Just started playing with vue-sweetalert2 and run into an issue.

Any suggestions would be much appreciated?

In my renderer main.js I do the import, yet I can't even try to use it, as it fails to import.

import VueSweetalert2 from 'vue-sweetalert2'

When running, I get the following:

Uncaught /my-project/node_modules/vue-sweetalert2/dist/index.js:1
(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { import Swal from 'sweetalert2';
                                                                                                                                                                  ^^^^
SyntaxError: Unexpected identifier
    at new Script (vm.js:83:7)
    at createScript (vm.js:265:10)
    at Object.runInThisContext (vm.js:313:10)
    at Module._compile (internal/modules/cjs/loader.js:712:26)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
    at Module.load (internal/modules/cjs/loader.js:645:32)
    at Function.Module._load (internal/modules/cjs/loader.js:560:12)
    at Module.require (internal/modules/cjs/loader.js:685:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at eval (webpack-internal:///vue-sweetalert2:1:18)

Here are the versions I am using for reference.

yarn list |egrep -i "alert|vue"
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    │  └─ [email protected]
    ├─ [email protected]
    ├─ [email protected]
    ├─ [email protected]

Uncaught TypeError: elem.cloneNode is not a function

2vendors.app.js:43192 Uncaught TypeError: elem.cloneNode is not a function
at handleJqueryElem (vendors.app.js:43192)
at parseHtmlToContainer (vendors.app.js:43178)
at renderTitle (vendors.app.js:43706)
at renderHeader (vendors.app.js:43728)
at render (vendors.app.js:43768)
at MixinSwal._main (vendors.app.js:45227)
at MixinSwal._main (vendors.app.js:43843)
at MixinSwal.SweetAlert (vendors.app.js:45412)
at new MixinSwal (vendors.app.js:43837)
at Function.fire (vendors.app.js:43807)

It could crash whole vue app. Happens when the route changes but vue triggers update at that time and sweetalert triggers. and this error

Use Minify Please

Hi @avil13 ,

Why you use "all" version of SweetAlert? Not a minify version?

import swal from 'sweetalert2';


Your bundle will more efficient, if you use a minify version like this.

// @ts-check
import swal from 'sweetalert2/dist/sweetalert2.min.js';
import 'sweetalert2/dist/sweetalert2.min.css';

Thank you

SyntaxError: Unexpected identifier

Error when using jest

import VueSweetalert2 from 'vue-sweetalert2';
localVue.use(VueSweetalert2);

Error :

 Test suite failed to run

    C:\Users\Ranieri\Documents\Projetos\electron\testerola\node_modules\vue-sweetalert2\dist\index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Swal from 'sweetalert2';
                                                                                                    ^^^^

    SyntaxError: Unexpected identifier

       7 | import { faUserSecret, faSignInAlt, faPaperPlane, faWindowClose, faFileUpload, faDesktop, faArrowDown, faArrowUp, faExpand, faHome, faDoorOpen, faCog } from '@fortawesome/free-solid-svg-icons'
       8 | import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
    >  9 | import VueSweetalert2 from 'vue-sweetalert2';
         | ^
      10 | //sweetalert

I want to bind html as vue-component

like this
this.$swal({
type: 'success',
target: document.getElementsByClassName('live-left')[0],
// text: 'hellllllll',
html: <PopupWindow></PopupWindow>
})

PopupWindow is my component

Can I do that?thank~!

Uncaught (in promise) TypeError: Cannot read property '$swal' of undefined at eval

Error: Login.vue?7463:59 Uncaught (in promise) TypeError: Cannot read property '$swal' of undefined at eval (Login.vue?7463:59)

Cannot use this.$swal inside catch block of axios. You @avil13 might help us.

login() {
      this.$http
        .post("login", { email: this.email, password: this.password })
        .then(response => {
           console.log(response.data);
        })
        .catch(function(error) {
          if (error.response.status === 401) {
            // alert("Invalid email or password!");
            this.$swal({
              type: "error",
              title: "Oops! " + error.response.statusText,
              html:
                "Please enter correct email & password"
            }).catch(swal.noop);
          }
        });
    }

Cannot find name 'SweetAlertOptions' after upgrading to v1.6.1

ERROR in /Users/dids/<project>/node_modules/vue-sweetalert2/src/index.d.ts
5:21 Cannot find name 'SweetAlertOptions'.
    3 |
    4 | declare interface swal {
  > 5 |     mixin(options?: SweetAlertOptions): typeof swal;
      |                     ^
    6 | }
    7 |
    8 | declare module 'vue/types/vue' {

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.