Skip to content
Advertisement

Binding on framework vue

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/vue@2.6.10/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

Advertisement

Answer

Your vue instance is not connected to your element.

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