From ccd921141d0b383f297070d19fdd0a541bd91c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=9F=D0=B8?= =?UTF-8?q?=D0=B2=D0=BA=D0=B8=D0=BD?= Date: Fri, 1 Nov 2019 19:44:24 +0300 Subject: [PATCH] fix fire method close #84 --- example/src/App.vue | 2 +- example/tsconfig.json | 2 +- package-lock.json | 2 +- package.json | 2 +- src/index.ts | 14 ++++++++------ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/example/src/App.vue b/example/src/App.vue index d289a0c..8b631a5 100644 --- a/example/src/App.vue +++ b/example/src/App.vue @@ -49,7 +49,7 @@ export default class AppComponent extends Vue { msg = 'Welcome to Vue-Sweetalert2 example'; simple() { - this.$swal('Hello world!'); + this.$swal.fire('Hello world!'); } // /* success() { diff --git a/example/tsconfig.json b/example/tsconfig.json index 68aca32..e7eaef6 100644 --- a/example/tsconfig.json +++ b/example/tsconfig.json @@ -18,7 +18,7 @@ "@/*": ["./src/*"] } }, - "files": ["vue-shims.d.ts", "**/*.d.ts"], + "files": ["vue-shims.d.ts"], "include": ["./src/**/*.ts", "./src/**/*.vue"], "exclude": ["node_modules"] } diff --git a/package-lock.json b/package-lock.json index 7084bc9..13f641a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vue-sweetalert2", - "version": "2.1.3", + "version": "2.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3df9e3f..088b2b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-sweetalert2", - "version": "2.1.4", + "version": "2.1.5", "description": "Simple Vue sweetalert2 package", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 31fa244..e59be67 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,7 +21,7 @@ interface VueSweetalert2Options extends SweetAlertOptions { class VueSweetalert2 { static install(vue: Vue | any, options?: VueSweetalert2Options): void { - const _swal = (...args: [SweetAlertOptions]) => { + const swalFunction = (...args: [SweetAlertOptions]) => { if (options) { const mixed = Swal.mixin(options); @@ -38,17 +38,19 @@ class VueSweetalert2 { Object.prototype.hasOwnProperty.call(Swal, methodName) && typeof Swal[methodName] === 'function' ) { - _swal[methodName] = (...args: any[]) => { - return Swal[methodName].apply(Swal, args); - }; + swalFunction[methodName] = (method => { + return (...args: any[]) => { + return Swal[method].apply(Swal, args); + }; + })(methodName); } } - vue['swal'] = _swal; + vue['swal'] = swalFunction; // add the instance method if (!vue.prototype.hasOwnProperty('$swal')) { - vue.prototype.$swal = _swal; + vue.prototype.$swal = swalFunction; } } }