{"id":99,"date":"2018-08-25T10:35:07","date_gmt":"2018-08-25T10:35:07","guid":{"rendered":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/?p=99"},"modified":"2018-08-25T10:35:07","modified_gmt":"2018-08-25T10:35:07","slug":"simplest-way-to-create-a-vue-instance","status":"publish","type":"post","link":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/simplest-way-to-create-a-vue-instance\/","title":{"rendered":"Simplest Way to Create a Vue Instance"},"content":{"rendered":"\n<p>A step by step guide to the simplest Vue.js app with no fluff.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"3024\" height=\"3024\" src=\"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/20171126_002448341_iOS.jpg\" alt=\"\" class=\"wp-image-114\" srcset=\"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/20171126_002448341_iOS.jpg 3024w, https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/20171126_002448341_iOS-150x150.jpg 150w, https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/20171126_002448341_iOS-300x300.jpg 300w, https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/20171126_002448341_iOS-768x768.jpg 768w, https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/20171126_002448341_iOS-1024x1024.jpg 1024w, https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/20171126_002448341_iOS-1200x1200.jpg 1200w\" sizes=\"(max-width: 3024px) 100vw, 3024px\" \/><\/figure>\n\n\n\n<p style=\"text-align:left\">Current cdn used:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>&lt;script src=&#8221;https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js&#8221;>&lt;\/script><\/p><\/blockquote>\n\n\n\n<p>Other places to get the cdn, https:\/\/cdnjs.com\/libraries\/vue<\/p>\n\n\n\n<p>Create app.js containing a data element with the label of &#8220;title&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"317\" height=\"237\" src=\"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/vue-hello-world.png\" alt=\"vue hello world\" class=\"wp-image-104\" srcset=\"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/vue-hello-world.png 317w, https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/vue-hello-world-300x224.png 300w\" sizes=\"(max-width: 317px) 100vw, 317px\" \/><\/figure>\n\n\n\n<p>&#8220;new Vue&#8221; creates the Vue instance<\/p>\n\n\n\n<p>&#8220;el&#8221; creates the Vue element, which is labeled &#8220;app&#8221;, this is referred to in the HTML page to create the view instance with the element of &#8220;app&#8221;.<\/p>\n\n\n\n<p>&#8220;data:&#8221; creates a property which will store the data the Vue instance will use.<\/p>\n\n\n\n<p>&#8220;title:&#8221; this is the property which contains the string, &#8216;Hello World&#8217;. This property gets called in the HTML using the double curly braces, {{}}.<\/p>\n\n\n\n<p><strong>The HTML page of &#8220;Hello World&#8221;<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"639\" height=\"326\" src=\"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/vue-hello-world-html.png\" alt=\"Vue html page hello world\" class=\"wp-image-105\" srcset=\"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/vue-hello-world-html.png 639w, https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/vue-hello-world-html-300x153.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/figure>\n\n\n\n<p>The Vue library is called with the cdn<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>&lt;script src=&#8221;https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js&#8221;>&lt;\/script><\/p><\/blockquote>\n\n\n\n<p>The Vue code we created is added by:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><\/blockquote>\n\n\n\n<p>The specific Vue element is called and a Vue instance created by<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>&lt;div id&#8221;app&#8221;><\/p><\/blockquote>\n\n\n\n<p>Everything between the &lt;div id&#8221;app>&lt;\/div> is within the Vue instance.<\/p>\n\n\n\n<p>Anything that is outside the specific Vue instance will be treated as HTML, Note: multiple Vue instances can be run on one webpage, although not quite sure what the benefit is.<\/p>\n\n\n\n<p><strong>What we see in the browser.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"303\" height=\"151\" src=\"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/simple-vue-app.png\" alt=\"simple-vue-app\" class=\"wp-image-110\" srcset=\"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/simple-vue-app.png 303w, https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-content\/uploads\/2018\/08\/simple-vue-app-300x150.png 300w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><\/figure>\n\n\n\n<p>We see the variable which has the property of &#8220;title&#8221;, in the browser it becomes a HTML element.<\/p>\n\n\n\n<p>Code for this app:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>app.js<\/p><p><\/p><p>new Vue({<br\/>el: &#8216;#app&#8217;,<br\/>data: {<br\/>title: &#8216;Hello World&#8217;<br\/>}<br\/>})<\/p><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>index.html<\/p><p><\/p><p>&lt;!DOCTYPE html><br\/>&lt;head><br\/><br\/>&lt;title>Document&lt;\/title><br\/>&lt;script src=&#8221;https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js&#8221;>&lt;\/script><br\/>&lt;\/head><br\/>&lt;body><br\/>&lt;h1>Simple Vue App&lt;\/h1><br\/>&lt;div id=&#8221;app&#8221;><br\/>&lt;h2>{{ title }}&lt;\/h2><br\/>&lt;\/div><br\/>&lt;script src=&#8221;app.js&#8221;>&lt;\/script><br\/>&lt;\/body><br\/><br\/>&lt;\/html><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>A step by step guide to the simplest Vue.js app with no fluff. Current cdn used: &lt;script src=&#8221;https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js&#8221;>&lt;\/script> Other places to get the cdn, https:\/\/cdnjs.com\/libraries\/vue Create app.js containing a data element with the label of &#8220;title&#8221; &#8220;new Vue&#8221; creates the Vue instance &#8220;el&#8221; creates the Vue element, which is labeled &#8220;app&#8221;, this is referred to &hellip; <a href=\"https:\/\/www.lyndonantcliff.com\/learning-to-code\/simplest-way-to-create-a-vue-instance\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Simplest Way to Create a Vue Instance<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/posts\/99"}],"collection":[{"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":11,"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/posts\/99\/revisions\/115"}],"wp:attachment":[{"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lyndonantcliff.com\/learning-to-code\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}