All language subtitles for 1) Vue Instance

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese Download
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,480 --> 00:00:02,260 This course assumes a basic knowledge 2 2 00:00:02,260 --> 00:00:05,120 of HTML, CSS, and JavaScript. 3 3 00:00:05,120 --> 00:00:06,590 We'll be covering everything you need to know 4 4 00:00:06,590 --> 00:00:08,020 to start building apps in Vue, 5 5 00:00:08,020 --> 00:00:10,160 or to add Vue to an existing project. 6 6 00:00:10,160 --> 00:00:11,530 Now before we dive into code, 7 7 00:00:11,530 --> 00:00:14,100 let's take a look at the project we'll be building. 8 8 00:00:14,100 --> 00:00:15,700 As you can see, it is a product page. 9 9 00:00:15,700 --> 00:00:17,770 We're gonna introduce new Vue concepts 10 10 00:00:17,770 --> 00:00:20,170 and add features as we go. 11 11 00:00:20,170 --> 00:00:22,520 Up here you can see that we have In Stock 12 12 00:00:22,520 --> 00:00:24,670 and below we have an Add to Cart button. 13 13 00:00:24,670 --> 00:00:26,160 Now when I hover over these colors, 14 14 00:00:26,160 --> 00:00:28,000 not only does the image change, 15 15 00:00:28,000 --> 00:00:31,250 but this Out of Stock and In Stock is changing, 16 16 00:00:31,250 --> 00:00:34,360 and that is disabling and enabling the button. 17 17 00:00:34,360 --> 00:00:37,770 We also have a Cart here, which we can add to, 18 18 00:00:37,770 --> 00:00:40,980 and we'll be developing some other features, such as tabs, 19 19 00:00:40,980 --> 00:00:43,140 and we'll work with forms to add reviews, 20 20 00:00:43,140 --> 00:00:45,660 so it'll be a pretty comprehensive application. 21 21 00:00:45,660 --> 00:00:48,840 I also wanted to show you the Vue DevTools. 22 22 00:00:48,840 --> 00:00:50,500 This is a really handy tool. 23 23 00:00:50,500 --> 00:00:51,720 It's not only gonna show you 24 24 00:00:51,720 --> 00:00:53,960 the structure of your application, 25 25 00:00:53,960 --> 00:00:56,440 but you can also dive in and see the data, 26 26 00:00:56,440 --> 00:00:59,730 the props, all sorts of useful information 27 27 00:00:59,730 --> 00:01:02,040 about what is happening with your application 28 28 00:01:02,040 --> 00:01:04,140 and with your individual components. 29 29 00:01:04,140 --> 00:01:05,530 You'll learn all about this. 30 30 00:01:05,530 --> 00:01:07,690 line:15% So please have this installed. 31 31 00:01:07,690 --> 00:01:10,390 line:15% I'm using Chrome and if you are using Chrome, 32 32 00:01:10,390 --> 00:01:12,670 line:15% and you're also running local files, 33 33 00:01:12,670 --> 00:01:16,390 line:15% make sure to have this clicked, Allow access to file URLs. 34 34 00:01:16,390 --> 00:01:19,790 line:15% This'll make sure that Vue activates on your project. 35 35 00:01:19,790 --> 00:01:21,530 line:15% All right, now that we have everything we need, 36 36 00:01:21,530 --> 00:01:23,180 let's start coding. 37 37 00:01:23,180 --> 00:01:25,190 Here's a code that we're starting off with. 38 38 00:01:25,190 --> 00:01:29,420 We've got an HTML file, and that is linked with a script tag 39 39 00:01:29,420 --> 00:01:31,410 down to our main.js. 40 40 00:01:31,410 --> 00:01:33,880 In our JavaScript, we have a variable called product, 41 41 00:01:33,880 --> 00:01:36,050 whose value is Socks. 42 42 00:01:36,050 --> 00:01:40,130 Now, we have a common problem in front-end development. 43 43 00:01:40,130 --> 00:01:43,960 We want to get this data into our HTML. 44 44 00:01:43,960 --> 00:01:47,630 Fortunately, Vue has a very simple way to do that. 45 45 00:01:47,630 --> 00:01:50,790 First, we'll go to vuejs.org 46 46 00:01:50,790 --> 00:01:53,570 and we'll look at the introduction page. 47 47 00:01:53,570 --> 00:01:55,410 We're gonna take this script here, 48 48 00:01:55,410 --> 00:01:57,350 copy it over and paste it, 49 49 00:01:58,700 --> 00:01:59,880 and this will install Vue. 50 50 00:01:59,880 --> 00:02:01,790 That's as simple as it gets. 51 51 00:02:01,790 --> 00:02:04,380 All right we're gonna change out our variable here 52 52 00:02:04,380 --> 00:02:08,870 and change it to app and make a new Vue instance. 53 53 00:02:08,870 --> 00:02:11,230 We're gonna pass in some information. 54 54 00:02:11,230 --> 00:02:13,930 So here we're putting an element property. 55 55 00:02:13,930 --> 00:02:16,630 We're going to say app, 56 56 00:02:16,630 --> 00:02:20,410 so this is going to connect to the div up here, 57 57 00:02:20,410 --> 00:02:22,720 with the id of app. 58 58 00:02:22,720 --> 00:02:26,290 So now our Vue instance is plugged into that div. 59 59 00:02:26,290 --> 00:02:27,730 We're also gonna give it some data. 60 60 00:02:27,730 --> 00:02:29,850 In this case, we're moving that variable, 61 61 00:02:29,850 --> 00:02:31,620 product = 'Socks'. 62 62 00:02:31,620 --> 00:02:33,210 Now it's becoming our data. 63 63 00:02:33,210 --> 00:02:35,450 If we refresh, we have the same information. 64 64 00:02:35,450 --> 00:02:38,320 That's because we haven't told that data where to go. 65 65 00:02:38,320 --> 00:02:40,790 So as you can see, Product goes here. 66 66 00:02:40,790 --> 00:02:43,840 So let's switch that out for product. 67 67 00:02:43,840 --> 00:02:47,630 And when we do that, that will pull in the actual product 68 68 00:02:47,630 --> 00:02:50,160 from our Vue instance's data. 69 69 00:02:50,160 --> 00:02:53,280 We refresh again, and Socks is appearing. 70 70 00:02:53,280 --> 00:02:54,730 Awesome, it worked! 71 71 00:02:54,730 --> 00:02:56,490 Now let's explore a little deeper, 72 72 00:02:56,490 --> 00:02:57,980 how this is actually working. 73 73 00:02:59,730 --> 00:03:02,460 In our JavaScript, we say new Vue. 74 74 00:03:02,460 --> 00:03:04,350 This creates a new Vue instance, 75 75 00:03:04,350 --> 00:03:06,660 which is the root of a Vue application. 76 76 00:03:06,660 --> 00:03:09,760 You can think of it like a heart, that powers everything. 77 77 00:03:09,760 --> 00:03:12,790 It's created by passing an options object into it, 78 78 00:03:12,790 --> 00:03:14,620 which has a variety of optional properties 79 79 00:03:14,620 --> 00:03:17,557 which are used to store data and perform actions. 80 80 00:03:17,557 --> 00:03:19,320 In order to form a relationship 81 81 00:03:19,320 --> 00:03:21,650 between the Vue instance and part of the DOM, 82 82 00:03:21,650 --> 00:03:23,580 we use the property el. 83 83 00:03:23,580 --> 00:03:26,270 Here we are specifying that we'd like to plug our instance 84 84 00:03:26,270 --> 00:03:28,630 into the div with the id of app. 85 85 00:03:28,630 --> 00:03:30,780 Now this div, and the content within it, 86 86 00:03:30,780 --> 00:03:32,740 is hooked up to our instance. 87 87 00:03:32,740 --> 00:03:35,540 The instance can also have a property for data. 88 88 00:03:35,540 --> 00:03:37,400 Here we're giving our instance a product, 89 89 00:03:37,400 --> 00:03:39,230 whose value is Socks. 90 90 00:03:39,230 --> 00:03:40,870 In order to display Socks, 91 91 00:03:40,870 --> 00:03:43,360 we're using these double curly braces up here. 92 92 00:03:43,360 --> 00:03:45,190 You can think of them somewhat like a phone, 93 93 00:03:45,190 --> 00:03:47,000 which has a direct line into another phone 94 94 00:03:47,000 --> 00:03:48,150 in the Vue instance. 95 95 00:03:48,150 --> 00:03:49,900 So when we reference product up here, 96 96 00:03:49,900 --> 00:03:52,700 it's as if we're asking our cell phone below, 97 97 00:03:52,700 --> 00:03:54,240 what's the value of product? 98 98 00:03:54,240 --> 00:03:56,610 And the phone says, Socks, 99 99 00:03:56,610 --> 00:03:58,650 and Socks appears on the webpage. 100 100 00:03:58,650 --> 00:04:01,090 This double curly brace syntax is called an Expression. 101 101 00:04:01,090 --> 00:04:02,980 You may already be familiar with them. 102 102 00:04:02,980 --> 00:04:05,190 They're used to produce or evaluate a value. 103 103 00:04:05,190 --> 00:04:06,550 You can use them to add a character, 104 104 00:04:06,550 --> 00:04:09,570 or number to your data, to combine values, 105 105 00:04:09,570 --> 00:04:12,323 to perform conditional logic with a ternary operator, 106 106 00:04:12,323 --> 00:04:14,430 to run methods on your data, 107 107 00:04:14,430 --> 00:04:16,280 along with a lot of other use cases. 108 108 00:04:17,330 --> 00:04:19,480 If we were to change Socks to Boots, 109 109 00:04:19,480 --> 00:04:22,140 our expression would receive the updated value product 110 110 00:04:22,140 --> 00:04:24,210 and the h1 would update accordingly. 111 111 00:04:24,210 --> 00:04:25,410 But why? 112 112 00:04:25,410 --> 00:04:27,110 Well, Vue is reactive. 113 113 00:04:27,110 --> 00:04:29,700 In other words, the instance's data is linked 114 114 00:04:29,700 --> 00:04:32,620 to every place that data is being referenced. 115 115 00:04:32,620 --> 00:04:35,920 So if we are referencing product in multiple elements, 116 116 00:04:35,920 --> 00:04:39,240 both elements would update to display product's new value. 117 117 00:04:39,240 --> 00:04:41,810 Anywhere that relies on our instance's data, 118 118 00:04:41,810 --> 00:04:44,000 will update when that data changes. 119 119 00:04:44,000 --> 00:04:45,150 Let's open the Console 120 120 00:04:45,150 --> 00:04:47,180 and show this reactivity happening live. 121 121 00:04:48,730 --> 00:04:50,740 So here I am, back in my application, 122 122 00:04:50,740 --> 00:04:52,730 and I'm gonna open the Console. 123 123 00:04:52,730 --> 00:04:54,890 And I'm gonna type in app, 124 124 00:04:54,890 --> 00:04:56,490 again that's the name of our Vue instance, 125 125 00:04:56,490 --> 00:04:58,750 then product, which is the name of our data, 126 126 00:04:58,750 --> 00:05:00,450 and I'm gonna give it a new value, 127 127 00:05:00,450 --> 00:05:01,840 Coat, in this case. 128 128 00:05:01,840 --> 00:05:03,480 Now Socks changes to Coat. 129 129 00:05:03,480 --> 00:05:06,750 If I change Coat, to say, Compass, 130 130 00:05:06,750 --> 00:05:08,300 Coat will change to Compass. 131 131 00:05:08,300 --> 00:05:09,133 So there it is. 132 132 00:05:09,133 --> 00:05:12,650 Our h1 is immediately updating with that new data value 133 133 00:05:12,650 --> 00:05:14,580 because of the reactivity system. 134 134 00:05:15,780 --> 00:05:17,550 All right, let's review. 135 135 00:05:17,550 --> 00:05:21,700 So the Vue instance is the heart of the application. 136 136 00:05:21,700 --> 00:05:24,230 It plugs in to an element in the DOM, 137 137 00:05:24,230 --> 00:05:26,080 and that element can use an expression 138 138 00:05:26,080 --> 00:05:28,210 to display that instance's data. 139 139 00:05:29,890 --> 00:05:31,580 Time for a challenge. 140 140 00:05:31,580 --> 00:05:33,890 Add a description to your data object. 141 141 00:05:33,890 --> 00:05:35,090 Then use an expression 142 142 00:05:35,090 --> 00:05:38,160 to display the description beneath the h1. 143 143 00:05:38,160 --> 00:05:40,610 You can find a link to the Code Playground below. 10935

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.