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>

  • try to put your <script> inside <body>? – Donald Wu Dec 30 '16 at 7:57
up vote 5 down vote accepted

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>

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.