Module 3 - Rendering conditional content and lists Flashcards

1
Q

what is v-if?

A

v-if is a Vue directive that based on a truthy/falsy value adds or removes a DOM element from the DOM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is v-show?

A

v-show is a Vue directive that either shows or hides using css a DOM element based on a truthy/falsy value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between v-if and v-show?

A

v-show hides or shows a DOM element with css while v–if removes the element completely from the DOM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is v-else

A

v-else allows for the next adjacent element to be displayed if the current element is not going to be displayed because v-if or v-else-if.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is v-else-if

A

v-else-if allows for the next adjacent element to be displayed if it meets a certain condition if the current element is not going to be displayed because v-if.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is v-for

A

v-for allow us to display a list of elements or a list of fields in an object. the syntax is v-for=”thing in things” {{thing}}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you get the index of the item currently being worked on in v-for

A

in order to get the index you need to use the following syntax <li>v-for=”(goal, index) in goals” {{goal}} - {{index}} </li>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you get the key in a v-for loop going over an object

A

You use the following syntax:

<li>v-for="(value,key) in {'name':'arik', age:47}" {{key}} - {{value}}</li>

You can also get the index using the following syntax

<li>v-for="(value,key,index) in {'name':'arik', age:47}" {{key}} - {{value}} - {{index}}</li>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What would the following syntax produce

li v-for=”val in 10”){{val}}(/li

A

This syntax will create a list with 1-10 as the values in each li

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what does @click.stop do?

A

@click.stop is a directive that binds the click event to a function but also prevents the event from propagating to other elements along the chain. If we don’t specify a method to be executed we just stop the propagation of the event without activating any method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the key attribute?

A

The key attribute is used to uniquely identify a DOM element in v-for. It should be used everywhere we use v-for to avoid reuse element bugs in Vue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly