URL: https://www.progressiverobot.com/vuejs-hello-world-vuejs/

<^>Vue.js<^> is quickly becoming a very popular option as a library for reactive components. It's lightweight, simple to grasp and fun to play with, and it can prove to be a great alternative to other libraries like React or Angular.

Let's get our feet wet with the simplest of examples. Here's the code for our basic Hello World app, with the interesting parts highlighted:

				
					
&lt;!DOCTYPE html&gt;

&lt;html lang="en"&gt;

  &lt;meta&gt;

    &lt;meta charset="UTF-8"&gt;

    &lt;title&gt;Hello World in Vue.js&lt;/title&gt;

  &lt;/meta&gt;



  &lt;body&gt;

	

    &lt;div id="hello-world-app"&gt;

      &lt;h1&gt;{{ msg }}&lt;/h1&gt;

    &lt;/div&gt;



    &lt;script

      src="//cdnjs.cloudflare.com/ajax/libs/vue/2.1.6/vue.min.js"&gt;

    &lt;/script&gt;



    &lt;script&gt;

      new Vue({

        el: "#hello-world-app",

        data() {

          return {

            msg: "Hello World!"

          }

        }

      });

    &lt;/script&gt;



  &lt;/body&gt;

&lt;/html&gt;

				
			

Step by step breakdown:

  • First we have a basic HTML boilerplate file.
  • A <^>div<^> with an id of <^>#hello-world-app<^> will contain our app.
  • In the div, we have an <^>h1<^> and a reference to an <^>msg<^> piece of data.
  • We call for the minified Vue.js library that's hosted on cdnjs. 2.1.6 is the latest version as of this writing.
  • We then instantiate a new <^>Vue<^> object and tell it with <^>el<^> that our app is the <^>#hello-world-app<^> div.
  • Finally, we provide the data needed with the <^>data<^> object. In this case, we provide the data for <^>msg<^>.

And that's it for this brief introduction! Learn more by reading the getting started section of the official Vue.js guide.