gpt4 book ai didi

javascript - 如何将 beforeOpen 和 beforeClose 监听器传递给 vue-js-modal 对话框?

转载 作者:搜寻专家 更新时间:2023-10-30 22:19:50 28 4
gpt4 key购买 nike

对于对话窗口,我使用了 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 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-------------//
}
})
}

},
});

在这种情况下,没有任何内容写入控制台

最佳答案

@imcvampire 的回答很完美,但如果您有任何疑问并想在这里举个例子,那就是:

https://github.com/euvl/vue-js-modal/blob/master/demo/client_side_rendering/src/components/SizeModal.vue

在 vue-js-modal 中。

关于javascript - 如何将 beforeOpen 和 beforeClose 监听器传递给 vue-js-modal 对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46417179/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com