Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,280 --> 00:00:05,120
Now let's use these special CSS classes,
2
00:00:05,120 --> 00:00:09,620
which are added by router-link to the created anchor tag.
3
00:00:09,620 --> 00:00:12,950
And for that here in TheNavigation.vue
4
00:00:12,950 --> 00:00:16,570
I will actually add a new selector here
5
00:00:16,570 --> 00:00:19,080
to this hover and active rule.
6
00:00:19,080 --> 00:00:21,110
And the that's anchor tag,
7
00:00:21,110 --> 00:00:25,540
which has the router-link-active class on it.
8
00:00:25,540 --> 00:00:29,340
So a.router-link-active,
9
00:00:29,340 --> 00:00:33,210
this tells CSS that I want to apply these styles
10
00:00:33,210 --> 00:00:37,990
to every anchor tag, which has this CSS class on it.
11
00:00:37,990 --> 00:00:40,160
And if I do that and saved this,
12
00:00:41,120 --> 00:00:43,840
you now notice Users is highlighted.
13
00:00:43,840 --> 00:00:46,870
If I click on Teams that stays highlighted,
14
00:00:46,870 --> 00:00:51,870
and that's how you can reflect on your page visually
15
00:00:52,060 --> 00:00:56,130
on your links, which link is currently active.
16
00:00:56,130 --> 00:00:57,460
Now as a side note,
17
00:00:57,460 --> 00:01:00,510
you have two classes on their router-link-active,
18
00:01:00,510 --> 00:01:02,660
which I'm using for styling here,
19
00:01:02,660 --> 00:01:06,000
but also router-link-exact-active.
20
00:01:06,000 --> 00:01:09,350
Now, the difference is that router-link-active
21
00:01:09,350 --> 00:01:12,490
would also be applied to this item here.
22
00:01:12,490 --> 00:01:16,920
If we had something like Teams, Team ID.
23
00:01:16,920 --> 00:01:21,150
So if we had some nested route to this route here,
24
00:01:21,150 --> 00:01:23,480
now we have learned about nested routes yet,
25
00:01:23,480 --> 00:01:25,860
so for in a moment, we can just ignore that.
26
00:01:25,860 --> 00:01:28,740
But the difference is that router-link-exact-active
27
00:01:28,740 --> 00:01:31,210
will only be applied to the navigation item
28
00:01:31,210 --> 00:01:33,770
that's fully matched by the current path.
29
00:01:33,770 --> 00:01:35,530
Whereas router-link-active
30
00:01:35,530 --> 00:01:37,980
will be applied to any navigation item,
31
00:01:37,980 --> 00:01:41,260
which contains a part of the currently active route.
32
00:01:41,260 --> 00:01:43,220
At the moment, we have no situation
33
00:01:43,220 --> 00:01:44,970
where we would have nested routes.
34
00:01:44,970 --> 00:01:47,250
So at the moment it's either both or nothing,
35
00:01:47,250 --> 00:01:49,730
but later we'll see the difference in action.
36
00:01:50,910 --> 00:01:52,410
For the moment, it's just important
37
00:01:52,410 --> 00:01:54,150
to be aware of these classes,
38
00:01:54,150 --> 00:01:57,420
which helped you style your application.
39
00:01:57,420 --> 00:01:59,650
You can also change those default classes
40
00:01:59,650 --> 00:02:01,480
in case you're not happy with them
41
00:02:01,480 --> 00:02:04,640
in main JS, where you create the router,
42
00:02:04,640 --> 00:02:06,570
you got more config options,
43
00:02:06,570 --> 00:02:07,490
and you've gotta linkActive
44
00:02:07,490 --> 00:02:11,000
and a linkExactActiveClass option,
45
00:02:11,000 --> 00:02:14,530
where you can use any other CSS class name
46
00:02:14,530 --> 00:02:15,620
you might wanna use
47
00:02:15,620 --> 00:02:18,720
instead of their router-link-active class,
48
00:02:18,720 --> 00:02:20,330
which would be the default.
49
00:02:20,330 --> 00:02:23,270
So if you want to go with just active, for example,
50
00:02:23,270 --> 00:02:24,890
you could override this here.
51
00:02:25,830 --> 00:02:28,420
And I'm doing that here so that we see it in action.
52
00:02:28,420 --> 00:02:31,510
I'm setting the active class to just active.
53
00:02:31,510 --> 00:02:33,950
And that means I need to change my styling here
54
00:02:33,950 --> 00:02:37,450
and select the anchor tag with the active class on it.
55
00:02:39,200 --> 00:02:41,950
And with that it still works.
56
00:02:41,950 --> 00:02:44,420
And now you can tell it's the active class
57
00:02:44,420 --> 00:02:46,960
besides the router-link-exact-active class
58
00:02:46,960 --> 00:02:48,110
that's being added.
59
00:02:48,110 --> 00:02:50,530
So you can configure things like that.
60
00:02:50,530 --> 00:02:52,010
But with that, let's move on
61
00:02:52,010 --> 00:02:54,680
and let's not focus too much on the styling here.
62
00:02:54,680 --> 00:02:57,960
Instead, let's dig a bit deeper into the router
63
00:02:57,960 --> 00:03:00,870
and learn more about the different options we have here
64
00:03:00,870 --> 00:03:03,680
and the different kinds of routes we can register.
4763
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.