Skip to content

Commit

Permalink
fix fire method close #84
Browse files Browse the repository at this point in the history
  • Loading branch information
Алексей Пивкин committed Nov 1, 2019
1 parent c63ab79 commit ccd9211
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 8 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
}
}
}
Expand Down

0 comments on commit ccd9211

Please sign in to comment.