For dialog window I used . I need perform some code after closing dialog, so how can I pass beforeOpen and beforeClose listeners to dialog?
Changes:
I added @before-open="beforeOpen" @before-close="beforeClose"
to <v-dialog>
and listed them in methods section, but still doesn't work
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{%=o.htmlWebpackPlugin.options.title || 'Undefended'%}</title>
</head>
<body>
<div id="app">
<form id="form2" v-on:submit.prevent="login">
<input type="email" v-model="signIn.email" placeholder="[email protected]">
<input type="password" v-model="signIn.password" placeholder="Password">
<input type="submit" value="Sign In">
</form>
<v-dialog @before-open="beforeOpen" @before-close="beforeClose"/>
</div>
<script src="/dist/build.js"></script>
</body>
</html>
main.js shorten version
import VModal from 'vue-js-modal'
Vue.use(VModal, {dialog: true});
new Vue({
el: '#app',
data: {
signIn: {
email: '',
password: ''
},
},
methods: {
beforeOpen: function () {
console.log("open")
},
beforeClose: function () {
console.log("close")
},
login: function () {
fireAuth.signInWithEmailAndPassword(this.signIn.email, this.signIn.password)
.then((user) => {
if (!user.emailVerified) {
//-------------dialog-------------//
this.$modal.show('dialog', {
title: 'Alert!',
text: 'Please verify your email',
buttons: [{
title: 'Send verification email',
handler: () => {}
}, {title: 'Close'}]
});
//-------------dialog-------------//
}
})
}
},
});
in this case nothing writes to the console
For dialog window I used https://github./euvl/vue-js-modal. I need perform some code after closing dialog, so how can I pass beforeOpen and beforeClose listeners to dialog?
Changes:
I added @before-open="beforeOpen" @before-close="beforeClose"
to <v-dialog>
and listed them in methods section, but still doesn't work
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{%=o.htmlWebpackPlugin.options.title || 'Undefended'%}</title>
</head>
<body>
<div id="app">
<form id="form2" v-on:submit.prevent="login">
<input type="email" v-model="signIn.email" placeholder="[email protected]">
<input type="password" v-model="signIn.password" placeholder="Password">
<input type="submit" value="Sign In">
</form>
<v-dialog @before-open="beforeOpen" @before-close="beforeClose"/>
</div>
<script src="/dist/build.js"></script>
</body>
</html>
main.js shorten version
import VModal from 'vue-js-modal'
Vue.use(VModal, {dialog: true});
new Vue({
el: '#app',
data: {
signIn: {
email: '',
password: ''
},
},
methods: {
beforeOpen: function () {
console.log("open")
},
beforeClose: function () {
console.log("close")
},
login: function () {
fireAuth.signInWithEmailAndPassword(this.signIn.email, this.signIn.password)
.then((user) => {
if (!user.emailVerified) {
//-------------dialog-------------//
this.$modal.show('dialog', {
title: 'Alert!',
text: 'Please verify your email',
buttons: [{
title: 'Send verification email',
handler: () => {}
}, {title: 'Close'}]
});
//-------------dialog-------------//
}
})
}
},
});
in this case nothing writes to the console
Share Improve this question edited Sep 26, 2017 at 6:21 Nodirbek Shamsiev asked Sep 26, 2017 at 3:01 Nodirbek ShamsievNodirbek Shamsiev 5521 gold badge11 silver badges23 bronze badges 2- Please add your HTML template – Quoc-Anh Nguyen Commented Sep 26, 2017 at 3:32
- I just used <v-dialog/> and it works nice – Nodirbek Shamsiev Commented Sep 26, 2017 at 4:16
3 Answers
Reset to default 3@imcvampire's answer is perfect, but if you have any doubts and want an example here it is:
https://github./euvl/vue-js-modal/blob/master/demo/client_side_rendering/src/ponents/SizeModal.vue
In vue-js-modal.
Thanks for using plugin.
v-dialog
does not currently support listeners. It is a very thin wrapper for modal
, more like example really. I think the solution for your problem will just to use modal directly with all its features.
You can set function in v-modal
event:
<v-dialog @before-open="beforeOpen" @before-close="beforeClose"/>
And you define 2 methods:
methods: {
beforeOpen() { console.log('open') },
beforeClose() { console.log('close') }
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744836212a4596275.html
评论列表(0条)