P
P
poolpyos2019-09-30 15:24:41
JavaScript
poolpyos, 2019-09-30 15:24:41

How to toggle modal window?

I have a standard Vue.js modal window, I need to switch the login component to register when the Sign Up button is clicked
5d91f3795cd02398663081.png
How can I do this?

Vue.component('login', {
    template: `#login-template`,
    data() {
        return {
            loginInput: '',
            passwordInput: ''
        }
    },

    methods: {
        sendRequest(e) {
            var self = this;

            axios.post('/', {
                name: this.loginInput,
                password: this.passwordInput
            })
                .then(function (res) {
                    /*if (response == "ok") {
                        window.location.replace("/")
                    }*/

                    if (res.data.auth == true) {
                        self.$emit('close', res.data);
                    }

                    else {
                        return;
                    }
                })

                .catch(function (error) {
                    console.log(error);
                });
        },

        signUpModal() {
        }
    }
});

Here is the JS component code
<div class="login-footer">
    <slot name="footer">
        <div class="change-mode">
              <button class="change-mode-reg" @click="signUpModal"">Sign up</button>
                 <div class="change-mode-line"></div>
         </div>
 </slot>
</div>

Here is the code of the component itself

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Drozdov, 2019-09-30
@bagzon

1) Via dynamic components https://ru.vuejs.org/v2/guide/components-dynamic-a...
2) Or better, via https://router.vuejs.org/ru/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question