From dd99fdc68bd63df16da973862e6921be2df4ff50 Mon Sep 17 00:00:00 2001 From: Natalia Tepluhina Date: Mon, 8 Apr 2019 16:24:45 +0300 Subject: [PATCH] Small fixes to mini 1 for CodeSandbox updates --- workshop/minis/mini1.md | 109 ++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 67 deletions(-) diff --git a/workshop/minis/mini1.md b/workshop/minis/mini1.md index da71390..fdc63ec 100644 --- a/workshop/minis/mini1.md +++ b/workshop/minis/mini1.md @@ -1,4 +1,4 @@ -# 🖥️ Mini Workshop 1: Build A Simple Pet Fetching Web App +# 🖥️ Mini Workshop 1: Build A Simple Pet Fetching Web App | **Project Goal** | Get started with Vue.js basics and simple API calls | | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -19,14 +19,12 @@ We're going to build an application to load random dog images and store them to Take a look at the code that was scaffolded by Code Sandbox for a basic Vue.js app. The file `main.js` is open by default. This is the main starting point of a Vue.js app. Note that in this file you import Vue from its npm package: `import Vue from "vue";`. Code Sandbox imports all the needed dependencies from npm to build the app. You can always check out the root `package.json` to find out which dependencies are needed. -`main.js` also initializes the app as a new Vue.js app and sets the div into which the app code will be injected. It also names the main component and sets the template's name: +`main.js` also initializes the app as a new Vue.js app and sets the div into which the app code will be injected. ```js new Vue({ - el: '#app', - components: { App }, - template: '', -}); + render: h => h(App), +}).$mount('#app'); ``` Open up `App.vue`. In this file, the 'home' component is built. It contains the three main parts of a Vue.js Single File Component (SFC): a template, a script block, and a style block. @@ -102,7 +100,7 @@ Check whether the dependency is installed by opening `package.json` and checking ```json "dependencies": { "vue": "^2.5.2", - "vuetify": "^1.3.8" + "vuetify": "^1.5.9" }, ``` @@ -144,25 +142,25 @@ Then, overwrite the current template in `App.vue` with this markup: ```html ``` @@ -179,8 +177,9 @@ At this point, we need to start populating our UI with some data. First thing we ```html + height="400px" + src="https://images.dog.ceo/breeds/chihuahua/n02085620_3407.jpg" +> ``` How cute! 🐶 @@ -216,9 +215,7 @@ data() { Now we have to change the template to make the `src` property _dynamic_, so it can use the value of the variable we just populated above. To do this we need a `v-bind` directive or its shortcut, `:`. Again in `App.vue`, edit the `` tag: ```html - + ``` ::: tip 💡 @@ -381,8 +378,7 @@ To display the favorite dogs we should make changes to our template. Let's add t - + @@ -400,7 +396,7 @@ You can see an empty card with a 'Delete' button right after the current dog vie To render a list of items based on an array Vue has a `v-for` directive, which will iterate through this array and render each item. Let's add this directive to our `v-flex` element in the array of favorite cards: ```html - + ``` Here `pet` is the reference to the _current array element_ and `index` is the _index of this element_ inside the array. @@ -416,9 +412,7 @@ You can see that our empty card disappeared. It's fine! We have an empty `favori One thing left to do is to bind `pet` (which will be the image link) to the `src` property of the `v-img` component: ```html - + ``` Now it's time to like some dogs 💖🐶! @@ -501,7 +495,7 @@ Now we have to bind this new method to 'Delete' button with a click handler: ```html - delete + delete ``` @@ -522,13 +516,9 @@ We have a `components` folder but for now it's empty. Let's create a new file he Open this file and add `` and `` tags. Now our file looks this way: ```html - + - + ``` Now copy the whole `v-card` component that contains the favorite dogs (it's near the bottom) from `App.vue` and paste it inside the template tag. You can delete it from `App.vue`. @@ -566,9 +556,7 @@ In our template in `Dog.vue` we should replace `pet` with `dog`, because we don' ```html