0

Here's a code:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue</title>
</head>

<body>
    <div id="root">
        <input v-model="message" placeholder="Msg">
        <p>Message you typed is: {{ message }}</p>
    </div>
    <script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
    <script>

        new Vue({
            data: {
                el: '#root',
                message: ''
            }
        });
    </script>
</body>
</html>

Why the binding doesn't work. I try from a video

https://laracasts.com/series/learn-vue-2-step-by-step/episodes/1 . 

Thank you

3 Answers 3

3

el key should be on the object passed to the Vue constructor and not inside data object (Reference)

new Vue({
  el: '#root',
  data: {
    message: ''
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="root">
  <input v-model="message" placeholder="Msg">
  <p>Message you typed is: {{message}}</p>
</div>

Sign up to request clarification or add additional context in comments.

Comments

2
new Vue({
    data: {
        el: '#root',
        message: ''
 }
});

should replace to

new Vue({
    el: '#root',
    data: {
        message: ''
    }
});

Comments

1

Your vue instance is not connected to your element.

    <script>
            new Vue({
                el: '#root',
                data: {
                    message: 'Hello World!'
                }
            });
    </script>

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.