1

I am gonna planning to use vue.js in a web application. but it could not loaded and not fired html in browser. Please look at my below code:


<!DOCTYPE html>
<html>
    <head>

<script> var app = new Vue({ el: '#app', data: { message: 'Hello Vue!' } });

</script>

&#060;/head&#062;

<body> <div id="app"> {{ message }} </div> <script src="https://unpkg.com/vue/dist/vue.js"></script>

</body> </html>

1
  • try to put your <script> inside <body>? Commented Dec 30, 2016 at 7:57

1 Answer 1

10

The problem is you're trying to create Vue instance before vue.js is loaded, so I think if you put your code after vue.js, your application will work fine.

<!DOCTYPE html>
<html>
<head></head>
<body>

<div id="app">
  {{ message }}
</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            message: 'Hello Vue!'
        }
    });

</script>

</body>
</html>
Sign up to request clarification or add additional context in comments.

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.