S
S
Sergeyjed2019-03-29 23:43:23
Vue.js
Sergeyjed, 2019-03-29 23:43:23

How to pass input value to vue.js props?

When you enter data into the form, an error immediately flies in the console

Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "name"

I googled it, but nothing helped. Apparently I'm wrong somewhere.
The documentation didn't help solve the problem.
The form as a component is used in different places
<form @submit.prevent="toSend">
                      <input placeholder="Ваше имя" type="text" name="name" id="name" required="" v-model.trim="name">
                      <input placeholder="Ваш телефон" type="text" name="phone" id="phone" required="" v-model.number="phone">
                      <input placeholder="Ваш e-mail" type="email" name="email" id="email" required=""
                             v-model.trim="email">
                            <input type="submit" value="отправить заявку">
            </form>

--------------------------------

  export default {
      props: ['task', 'titleMail', 'name', 'phone', 'email', 'titleForm'],
     ...

So I insert into the pages
<contactForm task="order" titleMail="test" titleForm="test"/>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question