2

error:'v-model' directives cannot update the iteration variable 'msg' itself vue/valid-v-model

<div v-for="(msg,name) in normal" :key="name">
<input type="text" v-model="msg">
</div>
    <script>
export default{
data(){
normal: {
        position: "bottom",
        message: "",
        open: false,
        timeout: 1500,
      }}}
</script>
1
  • 1
    data not date Commented Apr 7, 2020 at 3:17

2 Answers 2

2

You need to edit array/object variable from data directly. While accessing "msg" inside "for" loop you are only getting copy of item value, and not reference to object/array item.

The correct usage will be:

<div v-for="(msg, name) in normal" :key="name">
   <input type="text" v-model="normal[name]">
</div>
Sign up to request clarification or add additional context in comments.

3 Comments

Based on Your code there should be 4 inputs. Type something in normal.message. Input still empty? You need to provide some fiddle for this.
Please add some explanation to your answer by editing it, such that others can learn from it
Oops,it's my bad,I typev-model="normal['name']"and make the error
0

Try something like this:

   <v-checkbox
        v-for="(value, key, index) in activeDays"
        v-model="activeDays[key]"
        :key="index"
        :label="`${key}`"
        ></v-checkbox>
    
    
    
activeDays: {monday:false, tuesday:false}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.