[Vuejs]-How to call function from Vue.js to HTML page

0👍

You should move your vue.js script at the end of the body section as described in the Vue.js tutorial you are doing.

<!DOCTYPE html>
            <html lang="en">
            <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>Document</title>
            </head>
            <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js"></script>
            
            <body>
                <div id="app">
                    <h1>{{ message }}</h1>
                </div>
                <script src='./vue.js'></script>
            </body>
            </html>

More info on where to place your script tag: When to use the <script> tag in the head and body section of a html page?

0👍

You can also leave as it is and change from:

 <script src='./vue.js'></script>

To

<script defer src='./vue.js'></script>

Leave a comment