F
F
fostsinger2018-07-27 05:28:43
Vue.js
fostsinger, 2018-07-27 05:28:43

How to pass a parameter to a function of another Vue component?

You need to pass the email data to the child component of
the main component:

<template>
 <checkPhone
      v-show="isModalVisible"
      @close="closeModal"/>
</template
<script>
 import checkPhone from "~/components/auth/checkPhone.vue"
data() {
      return { email:""}
}
 methods: {
  components: { checkPhone }
      signin() {
  axios.post('auth/signin', {
          user: {
            email: this.email,
            password: this.password,
}
}
</script>

child:
<script>
 checkEmail() {
      axios.post('auth/signin/confirm', {
        user: {
          email:this.email,
          confirmation_code: this.confirmation_code
        }
}
}
</script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pashkevich, 2018-07-27
@fostsinger

In parent:

<template>
 <checkPhone
      v-show="isModalVisible"
      @close="closeModal"
      :email="email"
/>
</template>

In child:
<script>
 checkEmail() {
      axios.post('auth/signin/confirm', {
        user: {
          email:this.email,
          confirmation_code: this.confirmation_code
        }
}
}
export default {
  props:{
    email:{
      type: String,
    }
  }
}
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question