D
D
danilkokorin2021-08-09 16:48:25
Vue.js
danilkokorin, 2021-08-09 16:48:25

Vue TypeError: Cannot read property '_wrapper' of undefined why is it throwing an error on Vue?

Hello everyone, there is such a small question related to Vue. For some reason $event.target.value doesn't work. The browser displays this error Vue TypeError: Cannot read property '_wrapper' of undefined

The error itself appears in the browser when you try to enter something into the input
The code itself:

<form>
<input 
            v-bind:value="title" 
            @input="title = $event.target.value"
            class="input" type="text" placeholder="Название"
            >
<button 
            class="btn" 
            @click="createPost"
            >
            Добавить
            </button>
</form>
<div class="post" v-for="post in posts" v-bind:key="post.id">
            <div><strong>Название:</strong>{{ post.title }}</div>
            <div><strong>Описание:</strong>{{ post.body }}</div>
        </div>

export default {
        data() {
            return{ 
                posts: [
                    {id: 1, title: 'JavaScript', body: 'Язык'},
                    {id: 2, title: 'PHP', body: 'Язык'},
                    {id: 3, title: 'HTML', body: 'He Язык'},
                    {id: 4, title: 'css', body: 'He Язык'},
                ],
                title: '',
                body: '',
            }
        },
        methods: {
            creatPost() {
                const newPost = {
                    id: Data.now(),
                    title: this.title,
                    body: this.body,
                }
                this.posts.push(newPost);
            },
        }
    }

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