【发布时间】:2017-09-26 03:01:59
【问题描述】:
对于对话窗口,我使用了https://github.com/euvl/vue-js-modal。我需要在关闭对话框后执行一些代码,那么如何将 beforeOpen 和 beforeClose 监听器传递给对话框?
变化:
我将 @before-open="beforeOpen" @before-close="beforeClose" 添加到 <v-dialog> 并在方法部分列出了它们,但仍然不起作用
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@email.com">
<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 缩短版
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-------------//
}
})
}
},
});
在这种情况下,没有任何内容写入控制台
【问题讨论】:
-
请添加您的 HTML 模板
-
我刚用过
效果很好
标签: javascript vue.js vuejs2 vue-component